Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv working but ruby version not changing

❯ rbenv version
system (set by /Users/eric.nguyen/.rbenv/version)
                                                                                                                                                             
❯ rbenv local 2.4.2
                                                                                                                                                           

❯ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
                                                                                                                                                           
❯ rbenv global 2.4.2
                                                                                                                                                           
❯ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
                                                                                                                                                           
❯ rbenv version
2.4.2 (set by /Users/eric.nguyen/.ruby-version)
                                                                                                                                                           
❯ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
                                                                                                                                                           
❯ gem -v
2.0.14.1

Ruby version is is still 2.0.0p648

I'm on macOS Sierra 10.12.6.
I've done everything mentioned here

I've done:

  1. rbenv rehash
  2. put eval "$(rbenv init -)" in my .zshrc and source ~/.zshrc
  3. put $HOME/.rbenv/shims into $PATH (/Users/eric.nguyen/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/eric.nguyen/Library/Android/sdk/tools:/Users/eric.nguyen/Library/Android/sdk/platform-tools:/Users/eric.nguyen/.rbenv/shims)

But it still doesn't change ruby version.

like image 972
ericn Avatar asked Nov 03 '17 10:11

ericn


People also ask

Does Rbenv install Ruby?

Rbenv by itself does not install Ruby implementations at all. You simply give it the path to an already installed Ruby implementation. There are several projects that make installing Ruby implementations easier.

How do I choose a Ruby version?

Set Ruby version with rvm on Mac 0 on the command line. To switch to the system ruby, enter rvm use system . To switch back to the default, rvm default . The command rvm list will show all installed Rubies, including the current and default versions.


2 Answers

Restarting my computer resolve the issue.

❯ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]


❯ gem -v
2.6.13
like image 57
ericn Avatar answered Nov 12 '22 01:11

ericn


You always need to run rbenv rehash after you install a new ruby version using rbenv and also when you install a gem that has a command line options

like image 42
slashpai Avatar answered Nov 12 '22 03:11

slashpai