Home > Mobile >  How to install ruby on Mac using rbenv?
How to install ruby on Mac using rbenv?

Time:07-05

My problem is ruby -v is not showing the ruby version that I installed (that is 3.0.0).

I installed ruby using following commands using homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew install rbenv ruby-build
rbenv install 3.0.0
rbenv global 3.0.0

Now after this when I check for ruby installation I cant find it. also I'm getting following output for these commands.

SSVFWER-M-91FL:~ ssvfwer$ which -a ruby
/usr/bin/ruby

SSVFWER-M-91FL:~ ssvfwer$ ruby -v 
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]

SSVFWER-M-91FL:~ ssvfwer$ rbenv install 3.0.0
rbenv: /Users/ssvfwer/.rbenv/versions/3.0.0 already exists
continue with installation? (y/N) n

SSVFWER-M-91FL:~ ssvfwer$ ruby -v 
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]

SSVFWER-M-91FL:~ ssvfwer$ rbenv versions
  system
* 3.0.0 (set by /Users/ssvfwer/.rbenv/version)

Can you help me with what I'm missing out here ? why us ruby -v not showing 3.0.0 as ruby version because I want to use that ruby. How do I switch ?

CodePudding user response:

It looks like you skipped step 2, rbenv init. rbenv is tightly integrated with your shell and some shims must be installed by you.

You can debug it with curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

  • Related