RVM is loading with the wrong version of ruby?

泄露秘密 提交于 2020-01-02 23:38:10

问题


When I open terminal I see:

Last login: Sun Aug 26 15:33:57 on ttys001
Using /Users/me/.rvm/gems/ruby-1.9.3-p125
Running /Users/me/.rvm/hooks/after_use
Using /Users/me/.rvm/gems/ruby-1.9.3-p194
ruRunning /Users/me/.rvm/hooks/after_use
me-MacBook:site me$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

Where I want ruby 1.9.3. If I then type:

rvm use 1.9.3 --default

I get the below:

$ rvm use 1.9.3 --default
Using /Users/me/.rvm/gems/ruby-1.9.3-p194
Running /Users/me/.rvm/hooks/after_use

This allows me to use rails but when I reopen terminal I have to do this every single time. Is there a way to make this the default setting? I added it to my bash_profile but that does not seem to work. Here is my bash profile:

# Required for Ruby upgrade to 1.9.3
export RUBYOPT=-r openssl

export PATH=${PATH}:/opt/local/bin

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

# Sets the RVM profile on terminal load
rvm use ruby-1.9.3-p125
rvm use 1.9.3 --default

# RVM Requirements
export CC="/usr/local/bin/gcc-4.2"
export CFLAGS="-O2 -arch x86_64"
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"
export ARCHFLAGS="-arch i386"

# Postgresql
export PATH=/usr/bin:$PATH

Any help? Thanks


回答1:


When you run ruby -v in command prompt, you are actually running /usr/bin/ruby because you set /usr/bin in very first of $PATH env variable. You should move the following rvm initialize command to the end of bash profile.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

it should work. You don't need to run rvm use command in your bash profile once you set default ruby by --default flag.




回答2:


You should probably delete these lines from your bashrc:

# Sets the RVM profile on terminal load
rvm use ruby-1.9.3-p125
rvm use 1.9.3 --default

rvm should automatically load it's default profile when you open your terminal, so no need to set (and re-set for some reason) the version in your bashrc.

The --default option is only needed once, to indicate the selected version to be the default from then on.




回答3:


Try rvm alias create default 1.9.3.



来源:https://stackoverflow.com/questions/12134469/rvm-is-loading-with-the-wrong-version-of-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!