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

1.2k views Asked by At

I have ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] installed on an ubuntu system. I also have rvm installed which has ruby version ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]. I am using rvm installed ruby version to run my project. Can I make the rvm installed ruby as my default ruby environment? 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. Once I logged out and logged in again the system shows the default system ruby version. Please help.

3

There are 3 answers

0
Anirudh Rautela On BEST ANSWER

I found out the way to sort this problem if it helps anyone. I made a script test.sh as follows -

# 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.

0
Малъ Скрылевъ On

Use .rvmrc only incase you have to use complex initial scripting, otherwise use filepair .ruby-version, .ruby-gemset, so

$ cd your_project
$ echo "1.8.7" > .ruby-version
$ echo "your_project" > .ruby-gemset
$ cd ..
$ cd your_project
$ bunde install
1
Mehul Gurjar On

Hope you have set RVM environment settings to .bashrc or your .bash_profile file.

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.

if Ruby version specify you can try this sudo apt-get purge ruby1.9 or ruby2.x