简体   繁体   English

如何在Ubuntu中将rvm安装的ruby设置为系统默认ruby版本

[英]How to setup rvm installed ruby as system default ruby version in ubuntu

I have ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] installed on an ubuntu system. 我在ubuntu系统上安装了ruby 2.0.0p247(2013-06-27修订版41674)[x86_64-linux] I also have rvm installed which has ruby version ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] . 我还安装了具有ruby版本ruby 1.8.7(2013-06-27 patchlevel 374)[x86_64-linux]的 rvm。 I am using rvm installed ruby version to run my project. 我正在使用rvm安装的ruby版本来运行我的项目。 Can I make the rvm installed ruby as my default ruby environment? 我可以将rvm安装的ruby设置为默认的ruby环境吗? I used the command 我用的命令

rvm --default use 1.8.7

This command only made the rvm installed ruby version as default for the current login session. 该命令仅将rvm安装的ruby版本作为当前登录会话的默认版本。 Once I logged out and logged in again the system shows the default system ruby version. 登录并再次登录后,系统将显示默认的系统红宝石版本。 Please help. 请帮忙。

Use .rvmrc only incase you have to use complex initial scripting, otherwise use filepair .ruby-version , .ruby-gemset , so 使用.rvmrc只有柜面你必须使用复杂的初始脚本,否则使用filepair .ruby-version.ruby-gemset ,所以

$ cd your_project
$ echo "1.8.7" > .ruby-version
$ echo "your_project" > .ruby-gemset
$ cd ..
$ cd your_project
$ bunde install

Hope you have set RVM environment settings to .bashrc or your .bash_profile file. 希望您已将RVM环境设置设置为.bashrc或.bash_profile文件。

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

You can remove built-in Ruby version installed on Ubuntu by sudo apt-get purge ruby . 您可以通过sudo apt-get purge ruby删除Ubuntu上安装的内置Ruby版本。

if Ruby version specify you can try this sudo apt-get purge ruby1.9 or ruby2.x 如果Ruby版本指定,则可以尝试sudo apt-get purge ruby1.9或ruby2.x

I found out the way to sort this problem if it helps anyone. 我找到了解决此问题的方法,如果它可以帮助任何人。 I made a script test.sh as follows - 我做了一个脚本test.sh如下-

# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

    # First try to load from a user install
    source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

    # Then try to load from a root install
    source "/usr/local/rvm/scripts/rvm"

else

    printf "ERROR: An RVM installation was not found.\n"

fi

rvm use 1.8.7

On running this script it will try to load rvm and then automatically switch to rvm installed ruby version. 在运行此脚本时,它将尝试加载rvm,然后自动切换到rvm安装的ruby版本。

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

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