简体   繁体   中英

rvm switches to old ruby version after reboot against default set

Every time I startup my computer (Ubuntu 12.04 LTS), it loads ruby 1.8.7, even when ruby 2.1.1 is set as =* - current && default (upon rvm list ).

To change the version I use rvm use ruby-2.1.1

However, every single time I use the use command, I get the popular error message RVM is not a function... .

So, again every single time, I have to follow the same steps, ie first type [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" and only then switch to ruby-2.1.1 with rvm use ruby-2.1.1 . Then, also Rails switches automatically from 2-something to 4.1.4.

  1. How can I convince my machine to stay with the head versions even after reboot?
  2. What does the [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" do and how do I understand this syntax? (I can't see any command here, really - just the parameter -s)
  1. You can make rvm known to your bash sessions simply by updading your .bashrc :

    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc.

(Info: Your problem was that you invoked the previous scripts and the changes they made lasted only for your current bash session. Now it's executed every time you open bash)

  1. $HOME stands for /home/<>. So in your home folder there is a .rvm directory where a scripts directory is included. The "command" here is the script rvm. Hope it helps

Your problem is that RVM is not loaded when you open a terminal, you have to manually add the source at each instance of the Terminal.

You need to add rvm source to the bashrc or bash_profile to resolve this issue.

Open terminal:

echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

Or this (if using non-login shell):

echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc

This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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