简体   繁体   中英

Ruby through RVM fails

In constant battle to install Ruby 1.9.2 on an RPM system (OS is based off of CentOS), I'm trying again with RVM.

So once I install it, I then try to use it:

[root@quackwall ~]# rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p136
[root@quackwall ~]# ruby
bash: ruby: command not found
[root@quackwall ~]# which ruby
/usr/bin/which: no ruby in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

Now that's interesting; rvm info says something completely different:

[root@quackwall bin]# rvm info

ruby-1.9.2-p136:

  system:
    uname:       "Linux quackwall.highwow.lan 2.6.18-194.8.1.v5 #1 SMP Thu Jul 15 01:14:04 EDT 2010 i686 i686 i386 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.2.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p136"
    date:         "2010-12-25"
    platform:     "i686-linux"
    patchlevel:   "2010-12-25 revision 30365"
    full_version: "ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-1.9.2-p136"
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p136"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.2-p136/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-1.9.2-p136/bin:/usr/local/rvm/gems/ruby-1.9.2-p136@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p136/bin:bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/rvm/bin"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.2-p136"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.2-p136:/usr/local/rvm/gems/ruby-1.9.2-p136@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.2-p136"
    IRBRC:        "/usr/local/rvm/rubies/ruby-1.9.2-p136/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

So I have RVM that says one thing and bash which says another. Any suggestions on how to get this working?

Why are you using your root account?

[root@quackwall ~]

RVM is designed to work as a user's sandbox, unless you are doing a system wide install. For normal use installing using root permissions and paths will get it all screwed up.

Installing system wide is a lot more complicated so if it's just for you, use the standard install.

Also, notice that rvm use 1.9.2 points to:

/usr/local/rvm/gems/ruby-1.9.2-p136

but:

which ruby

has no /usr/local/rvm/gems/ruby-1.9.2-p136 in the search path:

/usr/bin/which: no ruby in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

If you intend to use system-wide installs, you either need to modify all ~/.bashrc or ~/.bash_profile files for all users, or adjust /etc/bashrc or /etc/profile .

I believe you didn't update your .bashrc as the directions noted.

Note, after updating .bashrc you will need to open a new bash terminal so it reloads the environment.

Note

I've completely revised/clarified my answer in light of guidance/insight from TheLQ .

Answer

I got Ruby through RVM on after fresh install of OSX 10.7. For me, rvm failed no matter what with single user rvm. Sudo combined with some permission and environment $PATH changes to my user made it happen. Here's what I did:

sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )</pre>
sudo rvm pkg install readline
sudo rvm install 1.9.3

Installing rvm from root user makes a shell script at /usr/local/rvm/scripts/rvm
Pulled code from this executable and placed it in my .bash_profile so that .bash_profile was saved as:

[[ -s "/usr/local/rvm/scripts/rvm" ]] ;
    true ${rvm_path:="/usr/local/rvm"}
    source "/usr/local/rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

The user group RVM was created during root user rvm install. Last thing I did was go to my preferences pane in OSX 10.7 and added my user to the new rvm group. Finally I reloaded my terminal and was able to install 1.9.3 through rvm single user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM