本文介绍了Ruby 安装的 RVM 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 RVM 网站上提到的单一指令(使用 git)安装了 RVM.

然后我使用以下方法安装了 Ruby 版本 1.9.2 和 1.8.7:

rvm install 1.9.2rvm 安装 1.8.7

但是,我找不到 Ruby 二进制文件.当我尝试执行命令时,出现以下错误:

[root@server1 support]# rvm 使用 1.9.2使用/usr/local/rvm/gems/ruby-1.9.2-p136[root@server1 支持]# ruby-bash: ruby​​: 命令未找到

这是rvm info的输出:

[root@server1 支持]# rvm 信息系统:系统:uname: "Linux server1.myserver.com 2.6.18-194.26.1.el5.028stab070.14 #1 SMP Thu Nov 18 16:34:01 MSK 2010 x86_64 x86_64 x86_64 GNU/Linux"bash: "/bin/bash => GNU bash, 版本 3.2.25(1)-release (x86_64-redhat-linux-gnu)"zsh:=> 未安装"房车:版本:rvm 1.2.6 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]"家:宝石:未设置"红宝石:未设置"二进制文件:红宝石:"irb:"宝石:"耙子:"环境:路径:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/rvm/bin"GEM_HOME:"GEM_PATH: ""MY_RUBY_HOME:""IRBRC:"红宝石:"宝石:"[root@server1 支持]#
解决方案

RVM 需要对 ~/.bashrc~/.bash_profile 进行少量添加以对其进行初始化当您登录时.它在安装后部分的安装文档中指定.你这样做了吗?

根据您的 rvm info 输出,您似乎还没有完成安装.输出中的所有条目都应具有相应的值.所以,我怀疑你没有添加:

[[ -s "$HOME/.rvm/scripts/rvm" ]] &&."$HOME/.rvm/scripts/rvm" # 这会将 RVM 加载到 shell 会话中.

到你的 ~/.bashrc~/.bash_profile 然后开始一个新的会话.

如果您正在进行多用户"安装,那么您需要做更多的事情.您是否修改了 /etc/profile,或者,如果您使用 Bash 作为 shell,您是否修改了 /etc/bash.bashrc 以包括:

# 如果已安装,则加载 RVM,# 首先尝试加载用户安装# 然后尝试加载 root 安装,如果用户安装不在那里.if [ -s "$HOME/.rvm/scripts/rvm" ] ;然后.$HOME/.rvm/scripts/rvm"elif [ -s "/usr/local/rvm/scripts/rvm"] ;然后./usr/local/rvm/scripts/rvm"菲

并启动了一个新的 shell?

我个人不喜欢多用户安装和单用户安装一样,也不推荐它,但您的里程可能会有所不同.

仅供参考:去年在 IRC 上与 RVM 维护人员的讨论中,他们告诉我他们不推荐系统范围的安装,而是推荐本地单用户"安装,即使是服务器也是如此.

>

I installed RVM using the single instruction mentioned at the RVM website (using git).

Then I installed Ruby version 1.9.2 and 1.8.7 using:

rvm install 1.9.2
rvm install 1.8.7

However, I cannot find the Ruby binary. When I try to execute the command, I get the following error:

[root@server1 support]# rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p136

[root@server1 support]# ruby
-bash: ruby: command not found

Here is the output of rvm info:

[root@server1 support]# rvm info

system:

  system:
    uname:       "Linux server1.myserver.com 2.6.18-194.26.1.el5.028stab070.14 #1 SMP Thu Nov 18 16:34:01 MSK 2010 x86_64 x86_64 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.2.6 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]"

  homes:
    gem:          "not set"
    ruby:         "not set"

  binaries:
    ruby:         ""
    irb:          ""
    gem:          ""
    rake:         ""

  environment:
    PATH:         "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""


[root@server1 support]#
解决方案

RVM requires a minor addition to your ~/.bashrc or ~/.bash_profile to initialize it when you log-in. It is specified in the installation docs in the Post Install section. Did you do that?


Per your rvm info output, it looks like you haven't completed your installation. All the entries in the output should have corresponding values. So, I suspect you haven't added:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

to your ~/.bashrc or ~/.bash_profile and then started a new session.

If you are doing a "Multi-User" installation then you'll need to do a lot more. Have you modified /etc/profile, or, if you are using Bash as your shell, have you modified /etc/bash.bashrc to include:

# Load RVM if it is installed,
#  first try to load  user install
#  then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
  . "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
  . "/usr/local/rvm/scripts/rvm"
fi

and started a new shell?

Personally I don't like the multi-user install as much as the single-user install, and don't recommend it but your mileage might vary.


As a FYI: In a discussion with the RVM maintainers on IRC last year, they told me they do not recommend the system-wide installation, and instead recommend the local "single-user" installation, even for servers.

这篇关于Ruby 安装的 RVM 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:29