如何使用 RVM 更改 Ruby 版本?
我无法切换当前的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
修好了。我需要添加:
到
.zshrc
Fixed it. I needed to add:
to
.zshrc
这也发生在我身上。我有:
添加到我的 .bashrc 中。
我所要做的就是将另一个文件添加
到同一个文件中,它就起作用了!
当然,之后您必须重新启动终端。
This happened to me too. I had:
Added in my .bashrc.
All I had to do was add another
to the same file and it worked!
Of course, you have to restart your terminal after that.
您的 shell 不知道 RVM 功能。安装后,它会告诉您如何处理这个问题。或者转至 RVM 站点上的 安装 页面并查看标题为“2.将 RVM 作为函数加载到 shell 会话中”
运行一次以添加将 rvm 加载到 ~/.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:
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)
(Kubuntu 11.10)
~/.bash_profile
现在称为~/.profile
(Kubuntu 11.10) The
~/.bash_profile
is now called~/.profile
更改 ruby 的默认版本:
在 Ubuntu 11.10 中
请更改您的 GNOME 终端设置:
转到终端,然后按照以下说明进行操作:
在终端上运行此命令:
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:
Run this command on terminal:
要将所有 RVM 功能添加到您的 .bash_profile,您应该使用以下命令:
之后您应该重新加载当前 shell 或打开一个新的终端会话,然后键入以下命令来重新加载 .bash_profile:
To add all RVM functionality to your .bash_profile you should use following command:
After that you should reload the current shell or open a new terminal session and type the following command to reload .bash_profile:
仅当为当前用户安装了 RVM 时,上述解决方案才有效。更通用的解决方案是使用 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:
我只需调用源
~/.bash_profile
I just had to invoke source
~/.bash_profile
在全新安装 Ubuntu 12.04 时,我遇到了同样的问题。 RVM 安装程序创建或附加到名为 ~/.bash_login 的文件中必要的代码位以避免最初的问题:
但是,这似乎没有被调用。将其添加到 ~/.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:
However this does not seem to get invoked. Adding it to ~/.bashrc resolved the issue for me.
安装 RVM,请参阅此处 http://octopress.org/docs/setup/rvm/
Installing RVM, See here http://octopress.org/docs/setup/rvm/
就我在 Ubuntu 上的情况而言, ~/.bashrc 中的条目有:
而不是:
请注意 .bashrc 之间缺少空格。和“$HOME。
另外,如果这是问题所在,那么当您启动终端时,您还应该注意到顶部有一个错误。
In my case on Ubuntu, the entry in ~/.bashrc had:
instead of:
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.
我全局安装了 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.