How do I change my Ruby version using RVM?

2019-01-10 00:59发布

I am not able to switch the current Ruby version:

➜  ~  rvm list

rvm rubies

   ruby-1.9.2-p290 [ x86_64 ]
   ruby-1.9.3-p0 [ x86_64 ]

➜  ~  rvm use ruby-1.9.3-p0

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

标签: ruby rvm
13条回答
叼着烟拽天下
2楼-- · 2019-01-10 01:07

I had a global install of RVM, which runs /etc/profile.d/rvm.sh. However, that script requires the BASH_VERSION or ZSH_VERSION to be set. I was running from crontab, which uses "sh".

I created a wrapper script that uses /bin/bash to source /etc/profile.d/rvm.sh.

查看更多
叼着烟拽天下
3楼-- · 2019-01-10 01:09

The above solution will only work, if RVM is installed for the current user. A more general solution would use the RVM path variable:

# The following code loads RVM as user or system install:
[[ -s "$rvm_path/scripts/rvm" ]] && . "$rvm_path/scripts/rvm"
查看更多
叛逆
4楼-- · 2019-01-10 01:09

You need to change your terminal emulator preferences to allow login shell. Sometimes it is required to use /bin/bash --login as the command.

查看更多
我只想做你的唯一
5楼-- · 2019-01-10 01:16

(Kubuntu 11.10) The ~/.bash_profile is now called ~/.profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.profile
source ~/.profile
rvm info # And now the fields display
查看更多
▲ chillily
6楼-- · 2019-01-10 01:16

To add all RVM functionality to your .bash_profile you should use following command:

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

After that you should reload the current shell or open a new terminal session and type the following command to reload .bash_profile:

source .bash_profile
查看更多
贼婆χ
7楼-- · 2019-01-10 01:18

To Change the Default Version of ruby:

In Ubuntu 11.10
please change your GNOME terminal setting :

Go to Terminal and then follow the following instructions:

1.  Edit > Profile Preferences
2.  Open Title and Command Tab               
3.  Check Run Command as a login Shell 
4.  Restart terminal

Run this command on terminal:

rvm --default use ruby_Version
查看更多
登录 后发表回答