【问题标题】:rvm not found while installing Ruby on Rails安装 Ruby on Rails 时找不到 rvm
【发布时间】:2011-08-21 04:23:47
【问题描述】:

我一直按照这个网站的教程在 Mac 上安装 Ruby on Rails:

http://ruby.railstutorial.org/

我安装了 rvm,但它不工作。教程说要输入这个命令:

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

在我这样做之后,它似乎已经成功加载,因为它是这样说的:

~ DUFF$ rvm reload 
RVM reloaded!
~ DUFF$ rvm notes
Notes for Darwin ( Mac OS X )
For Lion, Rubies should be built using gcc rather than llvm-gcc. Since
/usr/bin/gcc is now linked to /usr/bin/llvm-gcc-4.2, add the following to
your shell's start-up file: export CC=gcc-4.2
(The situation with LLVM and Ruby may improve. This is as of 07-23-2011.)

For Snow Leopard be sure to have Xcode Tools Version 3.2.1 (1613) or later
You should download the latest Xcode tools from developer.apple.com.
  (This is since the dvd install for Snow Leopard contained bugs).

If you intend on installing MacRuby you must install LLVM first.
If you intend on installing JRuby you must install the JDK.
If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).

To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):

rvm install 1.8.7 # installs patch 302: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7


NOTE: For all installations, as of 1.7, RVM no longer autoloads .rvmrc files. In order to       return this functionality, you MUST add 'export rvm_project_rvmrc=1' to your $HOME/.rvmrc file. This causes RVM to override 'cd' which, while toggleable even < 1.7, is currently defaulted to 'off'. This knob returns the previous behaviour to active which causes per-project .rvmrc files to be loaded once again.

示例:echo 'export rvm_project_rvmrc=1' >> $HOME/.rvmrc && rvm reload

所以我按照指示输入了这个:

type rvm | head -n1

它说:

-bash: type: rvm: not found

因此,经过长时间的介绍,我的问题是,您知道为什么在 rvm 类型似乎已安装后它无法识别它。我是一个完整的新手,所以请温柔。我遇到了很多问题,到目前为止,这似乎进展顺利。

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: ruby-on-rails installation rvm


    【解决方案1】:

    您在学习本教程吗? http://beginrescueend.com/rvm/install/

    您应该运行整个命令:

    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    

    这样,它会附加到您的 .bash_profile 文件中,并加载到每个新终端中。您输入的命令只会为单个终端会话加载 rvm 函数。

    .rvm/scripts/rvm 本身就是一个 shell 脚本,它将所有必要的功能加载到您的环境中。

    【讨论】:

    • 感谢您的回复。我尝试了该命令,但仍然得到相同的响应。但是,我是一个新手,我可能会错误地测试它。要查看它是否有效,我只需键入: rvm --version 这就是我查看它是否有效的方式。我仍然收到提示找不到 rvm 命令的错误。我很困惑。
    • 首先您应该通过运行cat ~/.bash_profile 来验证您是否正确运行了命令,并确保您在输出末尾看到[[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;&amp; . "$HOME/.rvm/scripts/rvm" # Load RVM function。如果你这样做了,按照@jonallard 的建议,要么打开一个新终端,要么运行命令source ~/.bash_profile 重新加载你的环境。您还应该通过列出目录ls ~/.rvm 来确保您拥有所有 rvm 脚本。您应该看到 bin、脚本、配置...等。如果一切都失败了,删除 rvm 目录sudo rm -R ~/.rvm 并从顶部开始。
    • 另外,如果你重新开始,我建议从最新的 git 版本安装,运行 bash &lt; &lt;(curl -s https://rvm.beginrescueend.com/install/rvm),注意 'bash' 不是你的 shell 提示符的占位符,它是命令的一部分。 ..抱歉过度解释,但不确定你是多么的菜鸟……哈哈
    • ~ DUFF$ rvm --version rvm 1.7.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [rvm.beginrescueend.com/] ~ DUFF$ ls ~/.rvm LICENSE config gemsets man tmp README contrib帮助 补丁 用户 VERSION 环境 钩子 rubies 包装器 档案 示例 lib 脚本 bin gems log src
    • 这就是我得到的。看起来它奏效了。我只需要关上窗户再试一次(表明我是个新手 :)
    【解决方案2】:

    看看the same question I posted some time ago.

    安装指南说要以这种方式在终端中“注册”RVM:

     user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    

    基本上,当您在 shell 中加载 RVM 函数时,您要放置指令的位置取决于您的发行版;这里是.bash_profile

    作为 Ubuntu 的用户,我发现使用 .bashrc 而不是 .bash_profile 效果更好。

    .bash_profile.bashrc 之间的区别在这里概述:http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

    【讨论】:

    • 感谢您的回复。我试过了,它似乎不起作用,虽然我已经把它弄乱了很多人的建议,我不确定我是否把它弄得更糟。我还检查了您提到的先前线程。它说要删除以前的安装并重试。如何删除以前的安装?对不起,新手的问题。我们必须从某个地方开始,对吧?
    • 发出user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;&amp; . "$HOME/.rvm/scripts/rvm" # Load RVM function' &gt;&gt; ~/.bashrc 后(注意“rc”,您是否尝试过关闭并重新打开终端窗口?
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多