rvm 安装无法正常工作:“RVM 不是一个功能”

发布于 2025-01-06 22:27:22 字数 380 浏览 4 评论 0原文

我刚刚安装了 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 技术交流群。

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

发布评论

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

评论(22

南风几经秋 2025-01-13 22:27:22

您需要运行以下命令

$ source ~/.rvm/scripts/rvm

,然后运行它

$ type rvm | head -n 1

,如果您得到

rvm is a function

问题就解决了。

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

来源:https://rvm.io/rvm/install/

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

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 requirements to see dependency requirements for your operating system

Source: 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.

空心↖ 2025-01-13 22:27:22

您没有使用登录 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 for ssh server "command" you are not using login shell and it would be required to run it with ssh server 'bash -lc "command"'.

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

娇纵 2025-01-13 22:27:22

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

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

To: ~/.bashrc file

Reason 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 :)

草莓酥 2025-01-13 22:27:22

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

source ~/.rvm/scripts/rvm

问题已解决。因为这一行将使 RVM 实例在特定时间成为一个函数。

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.

絕版丫頭 2025-01-13 22:27:22

最新的 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"

中二柚 2025-01-13 22:27:22

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

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.

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

只需执行命令“ruby -v”即可确认 RVM 使用的是更新版本的 Ruby。

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.

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

江湖正好 2025-01-13 22:27:22

我在新安装的 rvm 上也遇到了这个问题,这里的答案都没有修复它。进入 RVM 官方网站,在基础部分,他们有这个命令:

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

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

您应该将 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:

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

source $(rvm 1.9.3 do 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.

Bonjour°[大白 2025-01-13 22:27:22

即使您接受了答案,我还是想建议另一种方法.. ~/.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

风筝有风,海豚有海 2025-01-13 22:27:22

也许您可以尝试以下操作:

  • 您的终端 ->
  • 编辑->
  • 配置文件首选项 ->
  • 标题和命令 ->
  • 检查“作为登录 shell 运行命令”
  • 完成

Maybe you can try belows:

  • Your Terminal ->
  • Edit ->
  • Profile Preferences ->
  • Title and Command ->
  • Check the "Run command as a login shell"
  • Done
浅沫记忆 2025-01-13 22:27:22

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

Run bash --login and then run rvm use 2.0.0.

淡莣 2025-01-13 22:27:22

打开终端,然后转到编辑>配置文件首选项,然后转到选项卡“标题和命令”并选中“作为登录外壳运行命令”。

启动 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.

耳钉梦 2025-01-13 22:27:22

以上所有答案均有效。但当我遇到同样的问题时,解决方案如下:

  • 更新 ZSH。 (尝试直接更新由于某种原因不起作用。因此从此处卸载并重新安装更新版本)
  • 使用 sudo chsh -s $(which zsh) $USER 将默认 shell 设置为 zsh (即,如果您更喜欢 zsh)
  • 确保以下代码是在底部安装最新的 RVM 后,您的 .zshrc 可能使用 官方 RVM 站点

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && 。 “$HOME/.rvm/scripts/rvm”
    源~/.profile
    
  • 最重要的一点:确保在您的 .zshrc 文件中每次导出到路径是附加 :$PATH。即使按照上述步骤,我相信这也是问题的根源。

  • 发布此后,我的所有 RVM 不是函数 的问题都消失了。如果仍然不起作用,请在此处提供一些错误跟踪。经过几个小时的努力解决这个问题,我确信我一定已经看到了所有相关的错误。

希望有帮助。干杯!

All the above answers are valid. But when i faced the same issue, the solution was the following:

  • Update ZSH. (Tried to update directly din't work for some reason. So uninstalled and reinstalled updated version from here)
  • Set default shell as zsh (i.e. if you prefer zsh) using 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 site

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
    source ~/.profile
    
  • MOST IMPORTANT POINT: Ensure that in your .zshrc file every export to PATH 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!

断桥再见 2025-01-13 22:27:22

在 Mac OSX 10.8 Mountain Lion 上安装 Ruby 1.9.3-p125 的过程

  1. 您已经安装了最新的 XCode (>= 4.3) 和命令行 Objective-C
    编译器“叮当”。
  2. 您必须运行“bash”shell 才能使此过程生效。
  3. 转到系统偏好设置,
  4. 单击“用户和组”,
  5. 单击面板左下角的锁,然后输入密码将其解锁。
  6. “Ctrl-单击”面板左侧窗格中的用户图标,然后选择“高级选项...”
  7. 将登录 Shell 更改为“/bin/bash”
  8. 关闭首选项
  9. 打开终端窗口(按 command+空格键并键入在“终端”中)
  10. 按照以下说明进行操作:

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

  1. You've already installed the latest XCode (>= 4.3) and and the command line Objective-C
    compiler "clang".
  2. You must run the "bash" shell for this procedure to work.
  3. Go to System Preferences
  4. Click on "Users & Groups"
  5. Click the lock on the bottom left of the panel and enter your password to unlock it.
  6. "Ctrl-Click" on your user icon in the left pane of the panel and choose "Advanced Options..."
  7. Change the Login Shell to "/bin/bash"
  8. Close the preferences
  9. Open a terminal window (press command+spacebar and type in "terminal")
  10. Follow the instructions at:

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

盛夏已如深秋| 2025-01-13 22:27:22
source ~/.bash_profile

...应该可以解决问题...,可能需要注销并再次登录。

如何从命令行重新加载 .bash_profile?

source ~/.bash_profile

... should do the trick ..., probably need to logout and login again.

How to reload .bash_profile from the command line?

枯叶蝶 2025-01-13 22:27:22

我遇到了同样的错误,因为我曾经使用 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

晚雾 2025-01-13 22:27:22

« Official » instructions are there: https://rvm.io/integration/gnome-terminal/

睫毛溺水了 2025-01-13 22:27:22

我通过将此行添加到 .bash_profile 来修复它:

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

I fixed it by adding this line to .bash_profile:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
古镇旧梦 2025-01-13 22:27:22

我遇到了同样的错误,但此页面上的解决方案似乎都不起作用。对我来说,将 rvm 可执行文件添加到我的路径就足够了:

PATH=$PATH:/usr/local/rvm/bin/

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:

PATH=$PATH:/usr/local/rvm/bin/

Et voila!

梦断已成空 2025-01-13 22:27:22

我遇到了同样的问题,我在 .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".

铃予 2025-01-13 22:27:22

对于那些遇到同样问题并且像我一样使用 lubuntu 的人,我遵循了这个链接

您开始您的终端与

lxterminal -e“bash -il”

感谢@mpapsis 为我指明了正确的方向

For those who comes with same issue and they are using lubuntu like me I followed this link :

You start your terminal with

lxterminal -e "bash -il"

Thank to @mpapsis who pointed me to the right direction

以往的大感动 2025-01-13 22:27:22

我更改 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 容器,

docker run -it imagename `/bin/bash --login`

但在这种情况下,容器在后台保持打开状态,我无法输入命令。

我尝试了 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

docker run -it imagename `/bin/bash --login`

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"

音盲 2025-01-13 22:27:22

$ source ~/.rvm/scripts/rvm

如果您不想为每个终端选项卡一次又一次地执行此操作,请按照以下步骤启用登录 shell。

  1. 进入偏好设置
    在此处输入图片描述

  2. 启用作为登录 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.

  1. got to preferences
    enter image description here

  2. enable run command as a login shell
    enter image description here

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