开发者

How to set default Ruby version with RVM?

Ubuntu 11.

I do the following:

$ rvm --default use 1.9.2 and I get:

Using /home/md/.rvm/gems/ruby-1.9.2-p180 so that is good.

but when I now open a new terminal wind开发者_运维技巧ow I still get:

$ ruby -v

ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]


If you put the RVM source line in your bashrc (in order to ensure that non-interactive shells have access to RVM), you will need to source .bashrc from your .bash_profile with the following as the last lines in your .bash_profile

if [ -f "$HOME/.bashrc" ]; then
  source $HOME/.bashrc
fi

This pre-supposes that you have

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

in your $HOME/.bashrc. This is a good way to ensure that both interactive/login and non-interactive shells are able to find and load RVM correctly. Multi-User installs accomplish the same thing via the /etc/profile.d/rvm.sh file.

After that, you should have no problems defining a default Ruby to use via

rvm 1.9.2 --default

or

rvm use 1.9.2@mygemset --default

Its better to define a default gemset to use so as not to pollute your 'default' or 'global' gemsets.

If you are using non-interactive shells, be aware that they genereally operate in SH-compatibility mode which then requires you to set

BASH_ENV="$HOME/.bashrc"

in your $HOME/.profile in order you load RVM, or to set that within your script directly. The reason for this is that when bash is operating in SH mode it does not directly load .bash_profile or .bashrc as SH doesn't use those files, and bash is attempting to mimic the loading and execution process of the SH shell.


do an "rvm list" to see which Ruby versions you have installed.

then do this if you want to change the version only in one terminal session:

rvm use 1.8.7

if you want to select the default version for this user account, do this:

rvm use --default 1.9.2

See:

rvm use --help

See also this RailsCast:

http://railscasts.com/episodes/200-rails-3-beta-and-rvm

http://beginrescueend.com/


Late to party - anyway.

You did correctly set the default ruby version: rvm --default use 1.9.2

However, you need to update your Gemfile to the target ruby, because RVM references that file to select the working ruby version when you open terminal , that's why it reverted to the previous ruby version.


To Change the Default Version of ruby:

In Ubuntu

Go to default Terminal of Ubuntu and then follow the instructions:

1) Edit -> Profile Preferences
2) Select "Title and Command"
3) check "Run command as a login shell"
4) restart terminal

And after that run this command:

rvm --default use 2.2.4@gemset_name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜