rbenv工作,但红宝石版本没有改变

时间:2017-11-03 10:59:41

标签: ruby macos-sierra rbenv

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

driver-android git/V5-dev  
❯ rbenv local 2.4.2

driver-android git/V5-dev  
❯ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

driver-android git/V5-dev  
❯ rbenv global 2.4.2

driver-android git/V5-dev  
❯ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

driver-android git/V5-dev  
❯ rbenv version
2.4.2 (set by /Users/eric.nguyen/AndroidStudioProjects/driver-android/.ruby-version)

driver-android git/V5-dev  
❯ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

driver-android git/V5-dev  
❯ gem -v
2.0.14.1

Ruby版本仍然是2.0.0p648

我在macOS Sierra 10.12.6上 我做了所有提到的here

我做完了:

  1. rbenv rehash
  2. eval "$(rbenv init -)"放入我的.zshrc和source ~/.zshrc
  3. $HOME/.rbenv/shims放入$ 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)
  4. 但它仍然没有改变ruby版本。

2 个答案:

答案 0 :(得分:2)

重新启动计算机可解决此问题。

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


❯ gem -v
2.6.13

答案 1 :(得分:0)

使用rbenv安装新的ruby版本后,以及安装具有命令行选项的gem时,总是需要运行rbenv rehash