简体   繁体   中英

RVM is loading with the wrong version of ruby?

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

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.

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.

尝试使用rvm alias create default 1.9.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM