Ruby version not updating after install

Viewed 31

I successfully installed ruby version to 2.7, but ruby -v doesn't want to update. See output below:

āžœ  ~ ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]

Verify that Ruby 2.7 has been installed:

āžœ  ~ brew install ruby@2.7                        
Warning: ruby@2.7 2.7.6_1 is already installed and up-to-date.
To reinstall 2.7.6_1, run:
  brew reinstall ruby@2.7

What am I missing?

1 Answers

Type which ruby to find out where it's getting that executable from.

$ which ruby
/opt/homebrew/opt/ruby/bin/ruby

homebrew will put it in /opt/homebrew/opt/ruby/bin/ruby as shown there, but if that's not in your path then it will get the system ruby.

$ which ruby
/usr/bin/ruby

In that case you need to add the homebrew ruby bin directory to your PATH. I have this in my .bashrc:

export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH"
Related