如何使用 RVM 更改 Ruby 版本?

发布于 2024-12-23 09:31:03 字数 240 浏览 2 评论 0原文

我无法切换当前的 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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

后来的我们 2024-12-30 09:31:03

修好了。我需要添加:

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

.zshrc

Fixed it. I needed to add:

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

to .zshrc

两仪 2024-12-30 09:31:03

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

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

添加到我的 .bashrc 中。

我所要做的就是将另一个文件添加

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

到同一个文件中,它就起作用了!
当然,之后您必须重新启动终端。

This happened to me too. I had:

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

Added in my .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.

手心的海 2024-12-30 09:31:03

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

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

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

或者自己手动添加。 (请注意,在某些系统上,您可能希望将其放在其他位置,例如在我的系统 Mac OSX Lion 上,我将其放在 ~/.profile 中)

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"

Run this once to add the line that loads rvm into your ~/.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)

欲拥i 2024-12-30 09:31:03

(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

(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
£烟消云散 2024-12-30 09:31:03

更改 ruby​​ 的默认版本:

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

转到终端,然后按照以下说明进行操作:

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

在终端上运行此命令:

rvm --default use ruby_Version

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
A君 2024-12-30 09:31:03

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

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

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

source .bash_profile

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
揪着可爱 2024-12-30 09:31:03

仅当为当前用户安装了 RVM 时,上述解决方案才有效。更通用的解决方案是使用 RVM 路径变量:

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

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"
雨落星ぅ辰 2024-12-30 09:31:03

我只需调用源 ~/.bash_profile

I just had to invoke source ~/.bash_profile

心欲静而疯不止 2024-12-30 09:31:03

在全新安装 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*

但是,这似乎没有被调用。将其添加到 ~/.bashrc 解决了我的问题。

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:

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

绝影如岚 2024-12-30 09:31:03

就我在 Ubuntu 上的情况而言, ~/.bashrc 中的条目有:

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

而不是:

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

请注意 .bashrc 之间缺少空格。和“$HOME。

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

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

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

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

冷︶言冷语的世界 2024-12-30 09:31:03

我全局安装了 RVM,它运行 /etc/profile.d/rvm.sh。但是,该脚本需要设置 BASH_VERSION 或 ZSH_VERSION。我从 crontab 运行,它使用“sh”。

我创建了一个使用 /bin/bash 来获取 /etc/profile.d/rvm.sh 的包装器脚本。

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.

忘东忘西忘不掉你 2024-12-30 09:31:03

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文