如何使用RVM修改Ruby版本?

时间:2022-06-01 18:35:57

I am not able to switch the current Ruby version:

我无法切换当前的Ruby版本:

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

13 个解决方案

#1


121  

Fixed it. I needed to add:

固定它。我需要添加:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM 

to .zshrc

,. zshrc

#2


55  

This happened to me too. I had:

这也发生在我身上。我有:

export PATH=~/.rvm/bin:$PATH

Added in my .bashrc.

添加到我的. bashrc。

All I had to do was add another

我所要做的就是再加一个

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

to the same file and it worked! Of course, you have to restart your terminal after that.

对同一个文件,它工作了!当然,在那之后你必须重新启动你的终端。

#3


11  

Your shell doesn't know about the RVM function. After you install it, it tells you how to take care of this. Or go to the install page on the RVM site and check out the section titled "2. Load RVM into your shell sessions as a function"

你的shell不知道RVM函数。安装之后,它会告诉您如何处理这个问题。或者到RVM站点上的安装页面,查看标题为“2”的部分。将RVM加载到shell会话中作为函数

Run this once to add the line that loads rvm into your ~/.bash_profile:

运行一次,将装载rvm的行添加到~/.bash_profile中:

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

or manually add it yourself. (Note that on some systems, you will want to put it in other places, for example on my system, Mac OSX Lion, I put it in ~/.profile)

或者自己手工添加。(注意,在某些系统上,您可能想要将它放在其他地方,例如在我的系统Mac OSX Lion上,我将它放在~/.profile中)

#4


9  

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

(Kubuntu 11.10)~ /。bash_profile现在称为~/.profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.profile
source ~/.profile
rvm info # And now the fields display

#5


6  

To Change the Default Version of ruby:

更改ruby的默认版本:

In Ubuntu 11.10
please change your GNOME terminal setting :

在Ubuntu 11.10中,请更改GNOME终端设置:

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

#6


5  

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

要向.bash_profile添加所有RVM功能,您应该使用以下命令:

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:

之后,您应该重新加载当前shell或打开一个新的终端会话,并键入以下命令重新加载.bash_profile:

source .bash_profile

#7


4  

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

如果为当前用户安装了RVM,那么上述解决方案将只能工作。更一般的解决方案是使用RVM路径变量:

# The following code loads RVM as user or system install:
[[ -s "$rvm_path/scripts/rvm" ]] && . "$rvm_path/scripts/rvm"

#8


3  

I just had to invoke source ~/.bash_profile

我只需要调用source ~/.bash_profile

#9


3  

On a clean install of Ubuntu 12.04 I ran into the same issue. The RVM installer creates or appends to a file called ~/.bash_login the necessary bit of code to avoid the original problem:

在Ubuntu 12.04的干净安装上,我遇到了同样的问题。RVM安装程序创建或附加到一个名为~/的文件。bash_login用于避免原始问题所需的代码位:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

However this does not seem to get invoked. Adding it to ~/.bashrc resolved the issue for me.

然而,这似乎并没有被调用。将其添加到~ /。bashrc为我解决了这个问题。

#10


1  

Installing RVM, See here http://octopress.org/docs/setup/rvm/

安装RVM,请参见http://octopus ress.org/docs/setup/rvm/

#11


1  

In my case on Ubuntu, the entry in ~/.bashrc had:

在我的Ubuntu中,~/的条目。bashrc:(

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

instead of:

而不是:

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

Notice the missing space between . and "$HOME.

注意中间的空格。和“$ HOME。

Also, if this is the problem, you should also be noticing an error on top when you start your terminal.

另外,如果这是问题,当您启动终端时,您也应该注意到顶部有一个错误。

#12


0  

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

我有一个RVM的全局安装,它运行/etc/profile.d/rvm. shvm。但是,这个脚本需要设置BASH_VERSION或ZSH_VERSION,我正在运行crontab,它使用“sh”。

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

我创建了一个包装器脚本,该脚本使用/bin/bash作为源/etc/profile.d/rvm. sh。

#13


0  

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

您需要更改终端模拟器的首选项以允许登录shell。有时需要使用/bin/bash——作为命令登录。

#1


121  

Fixed it. I needed to add:

固定它。我需要添加:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM 

to .zshrc

,. zshrc

#2


55  

This happened to me too. I had:

这也发生在我身上。我有:

export PATH=~/.rvm/bin:$PATH

Added in my .bashrc.

添加到我的. bashrc。

All I had to do was add another

我所要做的就是再加一个

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

to the same file and it worked! Of course, you have to restart your terminal after that.

对同一个文件,它工作了!当然,在那之后你必须重新启动你的终端。

#3


11  

Your shell doesn't know about the RVM function. After you install it, it tells you how to take care of this. Or go to the install page on the RVM site and check out the section titled "2. Load RVM into your shell sessions as a function"

你的shell不知道RVM函数。安装之后,它会告诉您如何处理这个问题。或者到RVM站点上的安装页面,查看标题为“2”的部分。将RVM加载到shell会话中作为函数

Run this once to add the line that loads rvm into your ~/.bash_profile:

运行一次,将装载rvm的行添加到~/.bash_profile中:

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

or manually add it yourself. (Note that on some systems, you will want to put it in other places, for example on my system, Mac OSX Lion, I put it in ~/.profile)

或者自己手工添加。(注意,在某些系统上,您可能想要将它放在其他地方,例如在我的系统Mac OSX Lion上,我将它放在~/.profile中)

#4


9  

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

(Kubuntu 11.10)~ /。bash_profile现在称为~/.profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.profile
source ~/.profile
rvm info # And now the fields display

#5


6  

To Change the Default Version of ruby:

更改ruby的默认版本:

In Ubuntu 11.10
please change your GNOME terminal setting :

在Ubuntu 11.10中,请更改GNOME终端设置:

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

#6


5  

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

要向.bash_profile添加所有RVM功能,您应该使用以下命令:

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:

之后,您应该重新加载当前shell或打开一个新的终端会话,并键入以下命令重新加载.bash_profile:

source .bash_profile

#7


4  

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

如果为当前用户安装了RVM,那么上述解决方案将只能工作。更一般的解决方案是使用RVM路径变量:

# The following code loads RVM as user or system install:
[[ -s "$rvm_path/scripts/rvm" ]] && . "$rvm_path/scripts/rvm"

#8


3  

I just had to invoke source ~/.bash_profile

我只需要调用source ~/.bash_profile

#9


3  

On a clean install of Ubuntu 12.04 I ran into the same issue. The RVM installer creates or appends to a file called ~/.bash_login the necessary bit of code to avoid the original problem:

在Ubuntu 12.04的干净安装上,我遇到了同样的问题。RVM安装程序创建或附加到一个名为~/的文件。bash_login用于避免原始问题所需的代码位:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

However this does not seem to get invoked. Adding it to ~/.bashrc resolved the issue for me.

然而,这似乎并没有被调用。将其添加到~ /。bashrc为我解决了这个问题。

#10


1  

Installing RVM, See here http://octopress.org/docs/setup/rvm/

安装RVM,请参见http://octopus ress.org/docs/setup/rvm/

#11


1  

In my case on Ubuntu, the entry in ~/.bashrc had:

在我的Ubuntu中,~/的条目。bashrc:(

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

instead of:

而不是:

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

Notice the missing space between . and "$HOME.

注意中间的空格。和“$ HOME。

Also, if this is the problem, you should also be noticing an error on top when you start your terminal.

另外,如果这是问题,当您启动终端时,您也应该注意到顶部有一个错误。

#12


0  

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

我有一个RVM的全局安装,它运行/etc/profile.d/rvm. shvm。但是,这个脚本需要设置BASH_VERSION或ZSH_VERSION,我正在运行crontab,它使用“sh”。

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

我创建了一个包装器脚本,该脚本使用/bin/bash作为源/etc/profile.d/rvm. sh。

#13


0  

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

您需要更改终端模拟器的首选项以允许登录shell。有时需要使用/bin/bash——作为命令登录。