I'm trying to update my root version of ruby. It seems like the root directory isn't updating. Even with installing ruby through homebrew or with rbenv - ruby will update but running ruby -v continues to stay at version 2.6. I'm concerned the main root is wrong and I'm wondering how to fix this.
Running this command gets the following output:
ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
Running this command gets the following output:
rbenv version:
3.3.0 (set by /Users/ninajay/.ruby-version)
Running this command gets the following output:
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
ALSO when I run this, the following is my path:
env | grep PATH
PATH=/Users/ninajay/opt/miniconda3/bin:/Users/ninajay/opt/miniconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools
You don't want to update your "root" version of Ruby.
Since you're on Mac, you have a preinstalled version of Ruby at the path
/usr/bin/ruby. If anything, this is your "root" version of Ruby. The only good way to update this is to update macOS and hope Apple updated Ruby for you.If you install Ruby via homebrew or rbenv or rvm or whatever, it is a completely separate Ruby installation. For example it might be in
/opt/homebrew/bin/rubyor~/.rbenv/versions/3.1.2/bin/ruby.The question is: when you type
rubyin your shell, which one do you want it to run and what is the best way to get it to do that?First, you want to be running the rbenv version. The whole point of rbenv is that it lets you easily update ruby whenever you want and switch versions at will. That means you want
rubyto run~/.rbenv/shims/ruby. You can manually check if rbenv installed the version you want by running this directly:Now what is the best way to make
rubyrun that version? Read the instructions for your shell under "Configure your shell to load rbenv". This usually involves adding a line likeeval "$(~/.rbenv/bin/rbenv init - bash)"to your shell config, but it depends on which specific shell you are using. Again, you can test this manually by runningIf running
rubyever does something you don't expect you can also runtype -a rubyto see all the possible things your shell could run (in priority order). This can help you debug if something is misconfigured to run the wrong thing.