【问题标题】:RVM is not a function, selecting rubies with 'rvm use ...' will not workRVM 不是一个函数,使用“rvm use ...”选择红宝石将不起作用
【发布时间】:2014-07-20 17:03:20
【问题描述】:

列出 ruby​​ 版本

console:~$ rvm list

rvm rubies

ruby-2.0.0-p481 [ i686 ]

# => - current
# =* - current && default
#  * - default

尝试使用特定版本的 ruby​​

console:~$ rvm use 2.0.0

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.

【问题讨论】:

  • 你想做什么?
  • 你用什么终端?每个终端应用程序的登录 shell 设置都不同。或者,您可以 source $HOME/.profilesource $HOME/.bash_profile 其中 rvm 可能已经定义了它的 init 行。
  • 您需要将控制台作为登录 shell 运行。你有什么系统?
  • 终端 Gnome Ubuntu 12.04 lts
  • 如果您想知道登录和非登录 shell 之间的区别:unix.stackexchange.com/questions/38175/…

标签: ruby bash rvm


【解决方案1】:

您的控制台没有作为登录 shell 运行,因此无法访问 rvm 功能。如果您运行的是 Ubuntu,您可以:

  1. 打开控制台
  2. 选择编辑 -> 配置文件首选项
  3. 选择选项卡:标题和命令
  4. 复选框“作为登录 shell 运行命令”
  5. 重启终端

【讨论】:

  • 我这样做了,但没有奏效。问题依然存在。如何彻底删除 rvm?
  • 当然,您的 ~/.profile [[ -s "$HOME/.rvm/scripts/rvm" ]] && 中需要以下内容。 "$HOME/.rvm/scripts/rvm"
  • 我认为这可以解释得更多——“因此无法访问 rvm 函数”
  • 成功了。你能分辨出这两者的区别吗?
  • 在 OSX 上对我有用的是/bin/bash --login; source ~/.rvm/scripts/rvm; rvm use 2.4.0
【解决方案2】:

从您的终端输入bash --login。然后给rvm use 2.0.0

【讨论】:

  • @AdityaPednekar 因此,有时阅读错误/控制台消息实际上会有所帮助,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. 指定了详细信息。
  • 是的,它有助于意识到使用rvmnvm 相比是多么复杂
  • 感谢这对我有用,它节省了很多时间。
【解决方案3】:

您的 rvm 似乎没有正确加载“.bash_profile”。我已经通过打开终端在 MAC OS X 或 Ubuntu 14.04 中修复它并写入:

source ~/.rvm/scripts/rvm

【讨论】:

    【解决方案4】:

    我的环境是 OSX Yosemite。有同样的问题....通过添加以下解决了

    1) 编辑以下行并将其添加到 .bash_profile 文件中。

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

    2) 重启终端并再次尝试 RVM 命令

    【讨论】:

    • 您也可以将其添加到 ~/.bashrc 或 ~/.zshrc(如果您使用的是 zsh)。
    • 如果不想或者不能重启终端,可以编辑后运行source ~/.bash_profile
    【解决方案5】:

    如果您不想每次打开终端时都这样,请再次执行上面的建议,只需添加

    source ~/.rvm/scripts/rvm
    

    ~/.bashrc的末尾

    【讨论】:

    • 这个有帮助。
    • .. 需要重启吗?
    • @gordie 不,直接执行source ~/.bashrc
    【解决方案6】:

    错误是由于 rvm 没有像在登录 shell 中那样运行。因此尝试以下命令:

    /bin/bash --login
    

    您将能够在终端中作为登录 shell 立即运行 rvm 命令。

    【讨论】:

      【解决方案7】:

      与其他答案的原理相同,只是认为它比重新打开终端要快:)

      bash -l -c "rvm use 2.0.0"
      

      【讨论】:

      • 应该有人想出比所有这些更好的答案。这是这个问题的所有答案中唯一对我有用的项目,但这不是我一直想做的事情。我在 Mac OSX Sierra 上
      【解决方案8】:

      您需要将source ~/.rvm/scripts/rvm 添加到~/.your_shellrc file。从现在开始,当您加载 shell 时,将加载 rvm。

      例如:

      如果你使用的是zsh shell,需要添加~/.zshrc文件

      如果你使用的是bash shell,需要在~/.bashrc文件中添加

      然后打开一个新标签看看效果。

      【讨论】:

        【解决方案9】:

        对于 Ubuntu(18.08) 中的我来说,我在 .bashrc 中添加了以下行,它可以工作。

         source /home/username/.rvm/scripts/rvm
        

        请添加此行。

        【讨论】:

        • 谢谢!这在 MacOS 上对我有用!作为一个建议,我认为最好使用~ 来引用用户的主路径:source ~/.rvm/scripts/rvm :-)
        • 感谢您发布此答案。在 Ubuntu 20.04 上为我工作。
        【解决方案10】:

        在 ubuntu 19.1 中为我完成以下工作

        source ~/.rvm/scripts/rvm
        

        【讨论】:

        • 这对我使用 WSL2 Ubuntu 有效。谢谢?
        【解决方案11】:

        我认为这个更通用的解决方案

        echo 'source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
        

        【讨论】:

          【解决方案12】:

          来自新的 Ubuntu 16.04 安装

          1) 终端 => 编辑 => 配置文件首选项

          2) 命令选项卡 => 选中 Run command as a login shell

          3) 关闭并重新打开终端

          rvm --default use 2.2.4
          

          【讨论】:

            【解决方案13】:

            如果使用专用 ubuntu RVM 安装程序 https://github.com/rvm/ubuntu_rvm 安装 RVM,RVM 脚本的路径将不同 /usr/share/rvm/scripts/rvm。因此,要将其添加到您的 .bashrc 中,请运行以下命令:

            echo 'source "/usr/share/rvm/scripts/rvm"' >> ~/.bashrc
            

            【讨论】:

              【解决方案14】:

              FWIW- 我也遇到了这个问题,它是在取消 selenium 运行的情况下发生的。也许有一个子外壳被实例化并留在原地。我需要做的就是关闭那个终端窗口并打开一个新窗口。 (macOS Sierra)

              【讨论】:

                【解决方案15】:
                     Usually this is caused by shell initialization files. Search for PATH=... entries.
                     You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
                     To fix it temporarily in this shell session run: rvm use ruby-2.6.5
                     To ignore this error add "rvm_silence_path_mismatch_check_flag=1" to your "~/.rvmrc" file.
                

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2015-09-03
                  • 1970-01-01
                  • 2013-01-22
                  • 2011-09-15
                  相关资源
                  最近更新 更多