【问题标题】:OS X Mavericks install rvm WARNINGOS X Mavericks 安装 rvm 警告
【发布时间】:2013-11-07 08:13:01
【问题描述】:

在终端运行时:

$ curl -L https://get.rvm.io | bash -s

它似乎工作正常,但在最后的升级说明中它说

 * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/Users/steven/.bash_profile':

      source ~/.profile

我无法使用 RVM,出现错误

-bash: rvm: command not found'

我对终端和 Ruby 还很陌生,因此我们将不胜感激。

【问题讨论】:

    标签: ruby command-line terminal rvm


    【解决方案1】:

    当您安装 rvm 时,它的路径会添加到 ~/.bash_profile。正如您所注意到的,RVM 会在安装过程中向您发出警告。您可以在每次加载终端时运行 source ~/.profile,但这很麻烦。

    来自 bash 文档:

    当 bash 作为交互式登录 shell 或作为带有 --login 选项的非交互式 shell 调用时,它首先从文件 /etc/profile 中读取并执行命令(如果该文件存在)。读取该文件后,它会按顺序查找 ~/.bash_profile、~/.bash_login 和 ~/.profile,并从第一个存在且可读的文件中读取并执行命令。

    这意味着/.bash_profile 正在运行,而/.profile/.bashrc 将被忽略。

    要解决此问题,只需打开 .bash_profile 并复制顶部的 rvm 路径并将它们粘贴到 .bashrc 文件的顶部。打开一个新的终端窗口,它应该可以正常工作。 如果.bash_profile 为空,您可以删除它;如果您选择保留它,则可以将~/.profile 的内容复制并粘贴到其中。

    【讨论】:

    • 太棒了,伙计。谢谢你。就像我说的,我对终端很陌生,我将不得不查找如何在其他文件的顶部打开和粘贴路径。你有时间解释一下怎么做吗?
    • 当然,使用您最喜欢的文本编辑器即可。试试这个:nano ~/.bash_profile 进行更改时不要忘记关闭并重新打开终端。
    • 奇怪,你应该有/.bash_profile,因为 rvm 在安装过程中告诉过你。
    • 您想查找此行:[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$ 一旦您在 /.bash_profile 中找到它,复制它,然后将其粘贴到 /.profile
    • 是的,只需将其粘贴到那里。完成后,只需像这样删除~/.bash_profilerm ~/.bash_profile`(如果您从那里找到并复制了该行)。
    【解决方案2】:

    按照说明做。

    来自RVM Troubleshooting page

    如果您的 .bash_profile 没有在 OSX 上正确加载,您需要做以下三件事之一:

    Create a file named ~/.bash_profile and add the RVM source line there
    Add the RVM source line to ~/.profile
    In your terminal preferences, change the shell from the default of /usr/bin/login to /bin/bash.
    

    所以,请检查您的系统中是否有 /Users/steven/.bash_profile。如果存在,请打开文件并在文件末尾添加该行:

    source ~/.profile

    否则创建文件并添加它。

    【讨论】:

    • 仅供参考,在 .bash_profile 末尾添加 'source ~/.profile' 使下一个终端打开,甚至无法执行 ls
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    • 2013-11-01
    • 2014-10-17
    • 1970-01-01
    • 2014-11-30
    • 2014-03-05
    相关资源
    最近更新 更多