[Shopify]Update the version of Ruby used in the Shopify CLI to the latest version.

I was preparing to use Shopify’s CLI to develop themes.

After installing the necessary libraries according to the official documentation,

$ shopify theme dev

When I ran the development, I got an error asking me to increase the version of Ruby, so I responded.

Ruby version 2.6.10 is not supported

Make sure you have at least Ruby 2.7.5 installed on your system. Documentation.

目次

Update the Ruby version to 3.3.4.

First, check the installed version with rbenv -v.

$ rbenv -v
rbenv 1.3.0

Older.

Check the version of Ruby that can be installed with rbenv install -l.

$ rbenv install -l
3.1.6
3.2.4
3.3.4
jruby-9.4.8.0
mruby-3.3.0
picoruby-3.0.0
truffleruby-24.0.1
truffleruby+graalvm-24.0.1

Only latest stable releases for each Ruby implementation are shown.
Use `rbenv install --list-all' to show all local versions.

Check for the latest version and install Ruby. It takes time, so wait a while.

rbenv install [selected version]

% rbenv install 3.3.4
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.3.4.tar.gz...
-> curl -q -fL -o ruby-3.3.4.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.4.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  27.3M      0 --:--:-- --:--:-- --:--:-- 27.3M
==> Installing ruby-3.3.4...
ruby-build: using libyaml from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.4" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-libyaml-dir=/usr/local/opt/libyaml --with-ext=openssl,psych,+
-> make -j 8
-> make install
==> Installed ruby-3.3.4 to /Users/k.yamauchi/.rbenv/versions/3.3.4

NOTE: to activate this Ruby version as the new default, run: rbenv global 3.3.4

The version with * is the current version.

$ rbenv versions      
* system
  3.3.4

Switch version to 3.3.4.

$ rbenv global 3.3.4
$ rbenv versions    
  system
* 3.3.4 (set by /Users/test/.rbenv/version)

Here, check the version of ruby.

$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23]

Switch from mac Ruby to rvenv Ruby as the version is still old.

Export PATH so that the rvenv command can be run from anywhere,
eval to run the initialisation script.
After re-reading the ~/.zshrc file, the rbenv version is checked.

In summary, the first two commands add the rbenv configuration to the shell, and the source command reflects the configuration.

$ export PATH="$HOME/.rbenv/bin:$PATH"
$ eval "$(rbenv init -)"
$ source ~/.zshrc
$ rbenv versions                      
  system
* 3.3.4 (set by /Users/test/.rbenv/version)

Check the ruby version again.

$ ruby -v
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-darwin23]

It was confirmed to have been updated successfully.

Run shopify theme dev

The command can now be tapped and executed.

% shopify theme dev
よかったらシェアしてね!
目次