简体   繁体   English

Ruby指向系统ruby而不是ubuntu中的rvm

[英]Ruby pointing to system ruby rather than rvm in ubuntu

I use ubuntu 11.10 and I have installed rvm and have installed ruby 1.9.3 . 我使用ubuntu 11.10并安装了rvm并安装了ruby 1.9.3 My system has by default ruby 1.9.1 . 我的系统默认为ruby 1.9.1 Hence instead of pointing to the ruby installed by rvm, my system points to the default ruby. 因此,我的系统指向默认的ruby,而不是指向由rvm安装的ruby。 How can I change this behaviour? 我该如何改变这种行为?

I'll bet that you haven't configured your path correctly. 我敢打赌你没有正确配置你的路径。 Try 尝试

echo $PATH

Ive got 我有

/Users/matt/.rvm/rubies/ruby-1.9.3-p286/bin

before 之前

/usr/bin

If that isnt the case for you, then you can add this little script to your .bashrc 如果您不是这样,那么您可以将这个小脚本添加到.bashrc中

I do this because sometimes I want to use system ruby and sometimes I want to use rvm rubies. 我这样做是因为有时我想使用系统ruby,有时候我想使用rvm rubies。

rvmenv() {
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.                                                                           
}
#rvmenv

If you want to use rvm all the time you can just uncomment the last line, or you can just run 如果你想一直使用rvm,你可以取消注释最后一行,或者你可以运行

rvmenv

in a shell session. 在shell会话中。

RVM要求您使用登录shell,默认情况下它不会打开,因此您需要手动执行此操作https://rvm.io/integration/gnome-terminal/

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

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