Search code examples
ruby-on-railsrubyubunturvmruby-on-rails-2

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


Solution

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