rvm 安装无法正常工作:“RVM 不是一个功能”
我刚刚安装了 RVM,但无法使其工作。我的 .profile
文件末尾有这样一行:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
我尝试运行 source .profile
并重新启动终端,但是当我运行 rvm 时仍然使用 1.9 .2
我得到:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
我的系统是 Ubuntu 11.10。
I just installed RVM, but can't make it work. I have such line at the end of my .profile
file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
I tried to run source .profile
and restarting terminal, but still, when I run rvm use 1.9.2
I'm getting:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
My system is Ubuntu 11.10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
您需要运行以下命令
,然后运行它
,如果您得到
问题就解决了。
您还需要运行
user$ rvmrequirements
以查看操作系统的依赖项要求来源:https://rvm.io/rvm/install/
我忘了提到您需要将此代码放入 ~/.bashrc 或 ~/.zshrc 文件中,并且您不需要再次编写此代码。
You need to run the following
then run this
and if you get
the problem is solved.
You also need to run
user$ rvm requirements
to see dependency requirements for your operating systemSource: https://rvm.io/rvm/install/
I forget mention that you need to put this code into you ~/.bashrc or ~/.zshrc file and you will not need to write this code again.
您没有使用登录 shell。
此处描述了启用登录标志的过程,还有有关登录 shell 的一些详细信息可以在此处找到。
因此,您需要在 Gnome 终端设置中检查“作为登录 shell 运行”选项。设置标志后需要打开新终端。
有时需要将命令设置为
/bin/bash --login
。对于远程连接,了解运行交互式 ssh 会话和执行单个命令之间的区别非常重要。
运行 ssh 服务器,然后以交互方式与服务器一起工作时,默认情况下您使用登录 shell,一切都很好,但是对于 ssh 服务器“命令”,您没有使用登录 shell并且需要使用
ssh server 'bash -lc "command"'
来运行它。任何远程调用都可能遇到与使用 ssh 执行单个命令相同的问题。
You are not using an login shell.
The process of enabling the login flag is described here, also some details on what a login shell is can be found here.
Thus, you need to check the option "Run as login shell" in the Gnome terminal's settings. It is required to open new terminal after this setting the flag.
Sometimes it is required to set the command to
/bin/bash --login
.For remote connections it is important to understand the differene between running interactive
ssh
session and executing single commands.While running
ssh server
and then working with the server interactively you are using login shell by default and it's all fine, but forssh server "command"
you are not using login shell and it would be required to run it withssh server 'bash -lc "command"'
.Any remote invocation can have the same problem as executing single command with
ssh
.要永久解决此问题,只需剪切/粘贴以下行:
[[ -s "$HOME/.rvm/scripts/rvm" ]] &&源“$HOME/.rvm/scripts/rvm”
来自:
~/.bash_profile
文件到:
~/.bashrc
文件这样做的原因是 < code>.bashrc 每次进入终端时执行,
.bash_profile
每次登录时执行。这就是解决方案/bin/bash --login
有效的原因,但每次进入终端时都必须执行此操作。这样你就可以设置到下一个格式,然后你就会忘记所有这些:)To permanently resolve this just cut/paste following line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
From:
~/.bash_profile
fileTo:
~/.bashrc
fileReason this works is that
.bashrc
is executed each time you enter the terminal, and.bash_profile
each time you login. That is why solution/bin/bash --login
works, but you have to do that each time you enter the terminal. This way you are set until your next format, and you will forget all this by than :)我也面临这个问题。最后我在终端上执行了这一行。
问题已解决。因为这一行将使 RVM 实例在特定时间成为一个函数。
I too faced this problem. Finally i executed this line on terminal.
Problem is fixed. Because this line will make the RVM instance a function for a particular time.
最新的 RVM(rvm 1.11.6(稳定))停止在 Ubuntu(10.10 - 64 位 - nerdy gnat 或其他)上工作 - 我一直收到
“RVM 不是一个函数,使用‘rvm use ...’选择 rubies 不会工作。”
之前,我收到了消息,但“rvm 1.9.3-p0@rails321”可以工作。现在,它不起作用了——你根本无法改变宝石组。
没有任何效果,直到我发现这个 - 将此作为
/home/your-name/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] 中的最后一行&&源“$HOME/.rvm/scripts/rvm”
The latest RVM (rvm 1.11.6 (stable)) stopped working on Ubuntu (10.10 - 64 bit - nerdy gnat or whatever) - I kept getting
"RVM is not a function, selecting rubies with 'rvm use ...' will not work."
Before, I got the message, but 'rvm 1.9.3-p0@rails321' would work. Now, it wouldn't work - you couldn't change gemsets at all.
Nothing worked, until I found this - make this the LAST line in
/home/your-name/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
正如您所说,显示的错误可能是以下错误。
如上所述,只需在终端中输入“/bin/bash --login”(重新启动终端后),然后输入命令“rvm use 1.9.3”(例如),它将开始使用相同的版本。
只需执行命令“ruby -v”即可确认 RVM 使用的是更新版本的 Ruby。
As you said, the error shown could be the following one.
As said above, just type '/bin/bash --login' in your terminal (after restarting your terminal), then type the comand 'rvm use 1.9.3' (for e.g.) and it will start using the same version.
Just execute the command 'ruby -v' to confirm that the RVM is using the updated version of Ruby.
我在新安装的 rvm 上也遇到了这个问题,这里的答案都没有修复它。进入 RVM 官方网站,在基础部分,他们有这个命令:
您应该将 1.9.3 更改为您真正想要的 ruby 版本,无论 shell 类型如何,它都会使 rvm 成为一个函数。
I had this problem too on a fresh rvm installation, and non of the answers here fixed it. Going into the official rvm site, on the basics section, they have this command:
You should change 1.9.3 for the ruby version that you actually want, and it'll make rvm a function regardless of the shell type.
即使您接受了答案,我还是想建议另一种方法.. ~/.bashrc 在打开任何 shell 之前加载。在最后添加该行,您不需要任何登录 shell 的东西
even though you accepted an answer, i'd like to suggest another way .. ~/.bashrc is loaded before any shell is opened. Add that line at the end of that, and you don't need any of that login shell thing
也许您可以尝试以下操作:
Maybe you can try belows:
运行
bash --login
,然后运行rvm use 2.0.0
。Run
bash --login
and then runrvm use 2.0.0
.打开终端,然后转到编辑>配置文件首选项,然后转到选项卡“标题和命令”并选中“作为登录外壳运行命令”。
启动 Bash,现在您可以直接从终端安装 Gems,无需使用 sudo,并且出现错误“RVM 不是一个函数,使用‘rvm use ...’选择 rubies 将不起作用。 ”将被淘汰。
干杯。
Open Up the Terminal and then Go to Edit > Profile Preferences and then go to the Tab "Title and Command" and Check "Run Command as Login Shell".
Boot Up a Bash and Now you can install Gems directly from the terminal without the use of sudo and the error "RVM is not a function, selecting rubies with 'rvm use ...' will not work." will be eliminated.
Cheers.
以上所有答案均有效。但当我遇到同样的问题时,解决方案如下:
sudo chsh -s $(which zsh) $USER
将默认 shell 设置为 zsh (即,如果您更喜欢 zsh)确保以下代码是在底部安装最新的 RVM 后,您的
.zshrc
可能使用 官方 RVM 站点最重要的一点:确保在您的
.zshrc
文件中每次导出到路径
是附加:$PATH
。即使按照上述步骤,我相信这也是问题的根源。发布此后,我的所有 RVM 不是函数 的问题都消失了。如果仍然不起作用,请在此处提供一些错误跟踪。经过几个小时的努力解决这个问题,我确信我一定已经看到了所有相关的错误。
希望有帮助。干杯!
All the above answers are valid. But when i faced the same issue, the solution was the following:
sudo chsh -s $(which zsh) $USER
Ensure that the following code is at the bottom of your
.zshrc
after you have installed the latest RVM probably using CURL from official RVM siteMOST IMPORTANT POINT: Ensure that in your
.zshrc
file every export toPATH
is appended with:$PATH
. Which i believe was the root of my problems even after following the above steps.post this all my problems of RVM Not being a function went away. If it still does not work, give some error trace over here. After a few hours of struggle to solve this issue, i'm sure i must have seen all related errors.
Hope it helps. Cheers!
在 Mac OSX 10.8 Mountain Lion 上安装 Ruby 1.9.3-p125 的过程
编译器“叮当”。
http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
注意:
要安装 ruby,您可能需要指定 clang 编译器:
$ rvm install 1.9.3p125 --with-gcc=clang
如果RVM 抱怨未找到 /usr/local/rvm,您需要创建一个链接:
$ ln -s /Users/[您的用户名]/.rvm /usr/local/rvm
Procedure for installing Ruby 1.9.3-p125 on Mac OSX 10.8 Mountain Lion
compiler "clang".
http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
Notes:
To install ruby, you may need to specify the clang compiler:
$ rvm install 1.9.3p125 --with-gcc=clang
If RVM gripes about /usr/local/rvm not found, you need to create a link:
$ ln -s /Users/[your user name]/.rvm /usr/local/rvm
...应该可以解决问题...,可能需要注销并再次登录。
如何从命令行重新加载 .bash_profile?
... should do the trick ..., probably need to logout and login again.
How to reload .bash_profile from the command line?
我遇到了同样的错误,因为我曾经使用 apt-get 命令安装了旧的 rvm 版本 ruby-rvm 。
我通过删除脚本行来配置 .bashrc 文件中的旧 rvm 解决了该问题。
检查旧的 rvm 配置脚本,然后运行 source .profile
I'd got the same error because I'd ever installed the old rvm version ruby-rvm with the apt-get command.
I solved the problem by remove the script line to config the old rvm in .bashrc file.
Check the old rvm config script and then run source .profile
“官方”说明如下:https://rvm.io/integration/gnome-terminal/
« Official » instructions are there: https://rvm.io/integration/gnome-terminal/
我通过将此行添加到 .bash_profile 来修复它:
I fixed it by adding this line to .bash_profile:
我遇到了同样的错误,但此页面上的解决方案似乎都不起作用。对我来说,将
rvm
可执行文件添加到我的路径就足够了:Et voila!
I had the same error, but none of the solutions on this page seemed to work. For me it was enough to add the
rvm
executable to my path:Et voila!
我遇到了同样的问题,我在 .bash_profile 中执行了此操作,并且成功了。
源“$HOME/.rvm/scripts/rvm”
。I had the same issue and I did this in my .bash_profile and it worked.
source "$HOME/.rvm/scripts/rvm"
.对于那些遇到同样问题并且像我一样使用 lubuntu 的人,我遵循了这个链接:
您开始您的终端与
感谢@mpapsis 为我指明了正确的方向
For those who comes with same issue and they are using lubuntu like me I followed this link :
You start your terminal with
Thank to @mpapsis who pointed me to the right direction
我更改 ruby 版本的不干净方法是
rvm alias create default ruby-2.2.3 &&源 ~/.bashrc && rvm list
它可以工作,因为我的 ~/.bashrc 中有以下行,但奇怪的是它不会自动完成这项工作。
[[ -s "/usr/local/rvm/bin/rvm" ]] && source "/usr/local/rvm/bin/rvm"
我尝试使用 --login 连接到我的 docker 容器,
但在这种情况下,容器在后台保持打开状态,我无法输入命令。
我尝试了 zhc 和终端,并使用选项“open with
/bin/bash --login
”My unclean way to change of ruby version is
rvm alias create default ruby-2.2.3 && source ~/.bashrc && rvm list
it works because I have the line bellow in my ~/.bashrc but strangely it don't do the job automatically.
[[ -s "/usr/local/rvm/bin/rvm" ]] && source "/usr/local/rvm/bin/rvm"
I tried to connect with --login to my docker container
but in this case the container stay open in background and I can't enter commands.
I tried both zhc and terminal with the option "open with
/bin/bash --login
"$ source ~/.rvm/scripts/rvm
如果您不想为每个终端选项卡一次又一次地执行此操作,请按照以下步骤启用登录 shell。
进入偏好设置
在此处输入图片描述
启用
作为登录 shell 运行命令
在此处输入图片描述
$ source ~/.rvm/scripts/rvm
if you don't want to do it again and again for every terminal tab enable the login shell by following these steps.
got to preferences
enter image description here
enable
run command as a login shell
enter image description here