ruby rvm 安装不起作用:“RVM 不是功能”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9336596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:46:52  来源:igfitidea点击:

rvm installation not working: "RVM is not a function"

rubyrvm

提问by amorfis

I just installed RVM, but can't make it work. I have such line at the end of my .profilefile:

我刚刚安装了 RVM,但无法使其工作。我的.profile文件末尾有这样一行:

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

I tried to run source .profileand restarting terminal, but still, when I run rvm use 1.9.2I'm getting:

我试图运行source .profile并重新启动终端,但是,当我运行时,rvm use 1.9.2我得到:

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

My system is Ubuntu 11.10.

我的系统是 Ubuntu 11.10。

回答by Jorge García

You need to run the following

您需要运行以下命令

$ source ~/.rvm/scripts/rvm

then run this

然后运行这个

$ type rvm | head -n 1

and if you get

如果你得到

rvm is a function

the problem is solved.

问题已经解决了。

You also need to run user$ rvm requirementsto see dependency requirements for your operating system

您还需要运行user$ rvm requirements以查看操作系统的依赖项要求

Source: https://rvm.io/rvm/install/

来源: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. Cheers!

我忘了提到您需要将此代码放入 ~/.bashrc 或 ~/.zshrc 文件中,您将不需要再次编写此代码。干杯!

回答by mpapis

You are not using an login shell.

您没有使用登录 shell。

The process of enabling the login flag is described here, also some details on what a login shell is can be found here.

这里描述了启用登录标志的过程,也可以在此处找到有关什么是登录 shell 的一些详细信息。

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.

因此,您需要在 Gnome 终端的设置中选中“作为登录 shell 运行”选项。设置标志后需要打开新终端。

Sometimes it is required to set the command to /bin/bash --login.

有时需要将命令设置为/bin/bash --login.



For remoteconnections it is important to understand the differene between running interactive sshsession and executing single commands.

对于远程连接,了解运行交互式ssh会话和执行单个命令之间的区别很重要。

While running ssh serverand then working with the server interactively you are using login shell by default and it's all fine, but for ssh server "command"you are not using login shell and it would be required to run it with ssh server 'bash -lc "command"'.

在运行ssh server然后以交互方式使用服务器时,默认情况下您使用的是登录 shell,这一切都很好,但是因为ssh server "command"您没有使用登录 shell,因此需要使用ssh server 'bash -lc "command"'.

Any remote invocation can have the same problem as executing single command with ssh.

任何远程调用都可能与使用ssh.

回答by Haris Krajina

To permanently resolve this just cut/paste following line:

要永久解决此问题,只需剪切/粘贴以下行:

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

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

From: ~/.bash_profilefile

来自:~/.bash_profile文件

To: ~/.bashrcfile

至: ~/.bashrc档案

Reason this works is that .bashrcis executed each time you enter terminal, and .bash_profileeach time you login. That is why solution /bin/bash --loginworks, but you have to do that each time you enter terminal. This way you are set until your next format, and you will forget all this by then :)

这样做的原因.bashrc是每次进入终端和.bash_profile每次登录时都会执行。这就是解决方案/bin/bash --login有效的原因,但每次进入终端时都必须这样做。这样您就可以设置为下一个格式,届时您将忘记这一切:)

回答by Bastin Robin

I too faced this problem. Finally i executed this line on terminal.

我也遇到了这个问题。最后我在终端上执行了这一行。

source ~/.rvm/scripts/rvm

Problem is fixed. Because this line will make the RVM instance a function for a particular time.

问题已修复。因为这一行将使 RVM 实例成为特定时间的函数。

回答by Rod McLaughlin

The latest RVM (rvm 1.11.6 (stable)) stopped working on Ubuntu (10.10 - 64 bit - nerdy gnat or whatever) - I kept getting

最新的 RVM(rvm 1.11.6(稳定))在 Ubuntu(10.10 - 64 位 - nerdy gnat 或其他)上停止工作 - 我一直在得到

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

“RVM 不是一个函数,选择带有 'rvm use ...' 的红宝石是行不通的。”

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.

之前,我收到了消息,但“rvm 1.9.3-p0@rails321”会起作用。现在,它不起作用 - 你根本无法改变宝石。

Nothing worked, until I found this - make this the LAST line in /home/your-name/.bashrc

没有任何效果,直到我发现这个 - 把它作为最后一行 /home/your-name/.bashrc

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

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

回答by Rajesh Omanakuttan

As you said, the error shown could be the following one.

正如您所说,显示的错误可能是以下错误。

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

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command. 
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

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.

如上所述,只需在终端中输入“ /bin/bash --login”(重新启动终端后),然后输入命令“rvm use 1.9.3”(例如),它将开始使用相同的版本。

Just execute the command 'ruby -v' to confirm that the RVM is using the updated version of Ruby.

只需执行命令 'ruby -v' 以确认 RVM 正在使用更新版本的 Ruby。

回答by vcanales

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:

我在新的 rvm 安装中也遇到了这个问题,这里的答案都没有解决。进入官方 rvm 站点,在基础部分,他们有以下命令:

# from http://rvm.io/rvm/basics

source $(rvm 1.9.3 do rvm env --path)

# 来自http://rvm.io/rvm/basics

源 $(rvm 1.9.3 做 rvm env --path)

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.

你应该为你真正想要的 ruby​​ 版本更改 1.9.3,它会使 rvm 成为一个函数,而不管 shell 类型如何。

回答by Feuda

Maybe you can try belows:

也许您可以尝试以下方法:

  • Your Terminal ->
  • Edit ->
  • Profile Preferences ->
  • Title and Command ->
  • Check the "Run command as a login shell"
  • Done
  • 您的终端 ->
  • 编辑 ->
  • 个人资料偏好 ->
  • 标题和命令 ->
  • 检查“作为登录shell运行命令”
  • 完毕

回答by kapv89

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

即使您接受了答案,我还是想建议另一种方式 .. ~/.bashrc 在打开任何 shell 之前加载。在末尾添加该行,您就不需要任何登录 shell 了

回答by Gowri Tumma

Run bash --loginand then run rvm use 2.0.0.

运行 bash --login然后运行rvm use 2.0.0