简体   繁体   English

RVM正在加载错误版本的ruby?

[英]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. 我想要红宝石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. 我将其添加到我的bash_profile中,但这似乎不起作用。 Here is my bash profile: 这是我的bash个人资料:

# 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. 在命令提示符下运行ruby -v时,实际上是在运行/usr/bin/ruby因为您在$PATH env变量的第一个设置了/usr/bin You should move the following rvm initialize command to the end of bash profile. 您应该将以下rvm initialize命令移至bash配置文件的末尾。

[[ -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. 通过--default标志设置默认红宝石后, --default在bash配置文件中运行rvm use命令。

You should probably delete these lines from your bashrc: 您可能应该从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. 当您打开终端时,rvm应该会自动加载其默认配置文件,因此无需在bashrc中设置(并出于某种原因重新设置)版本。

The --default option is only needed once, to indicate the selected version to be the default from then on. --default选项仅需要使用一次,以指示所选版本从那时起为默认版本。

尝试使用rvm alias create default 1.9.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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