安装ruby gem后,运行新gem会返回“找不到”错误

时间:2012-03-08 18:01:04

标签: ruby-on-rails ruby gem rvm

Fresh Ubuntu 10.04安装:

我在让我的宝石安装过程很好地运行时遇到了一些麻烦。每当我安装一个gem时,它都会经历一个简单明了的过程,没有任何问题:

$ gem install rails
Successfully installed rails-3.2.2
1 gem installed

然后验证版本,也许是一个简单的“rails -v”?都能跟得上:

$ rails -v
/home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /home/pragone/.rvm/gems/ruby-1.9.3-p125/bin/rails:18:in `<main>'

所以让我们确保安装了栏杆:

$ gem install railties
Successfully installed railties-3.2.2
1 gem installed

并尝试再次获得rails的版本:

$ rails -v
/home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /home/pragone/.rvm/gems/ruby-1.9.3-p125/bin/rails:18:in `<main>'

几乎我安装的所有宝石都会发生这种情况。我试着寻找一些关于如何用gem安装东西的文档,但找不到任何东西。似乎有些宝石安装在一个位置,有些宝石安装在另一个位置,其中一个位置不在我的路径中。有什么想法在这里发生了什么?

编辑:请求的信息:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.17
  - RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/pragone/.rvm/gems/ruby-1.9.3-p125
  - RUBY EXECUTABLE: /home/pragone/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
  - EXECUTABLE DIRECTORY: /home/pragone/.rvm/gems/ruby-1.9.3-p125/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/pragone/.rvm/gems/ruby-1.9.3-p125
     - /home/pragone/.rvm/gems/ruby-1.9.3-p125@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - http://rubygems.org/

和rvm info:

system:

  system:
    uname:       "Linux domU-12-31-39-0A-34-6E 2.6.32-311-ec2 #23-Ubuntu SMP Thu Dec 2 11:14:35 UTC 2010 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.10.3 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]"
    updated:      "2 hours 40 minutes 7 seconds ago"

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

  binaries:
    ruby:         "/usr/bin/ruby"
    irb:          "/usr/bin/irb"
    gem:          "/usr/bin/gem"
    rake:         "/home/pragone/.rvm/bin/rake"

  environment:
    PATH:         "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/pragone/.rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""

此外,通过上面列出的PATH,我在尝试运行rails时得到了这个:

The program 'rails' is currently not installed.  You can install it by typing:
sudo apt-get install rails

然而,上述错误发生在我被黑客攻击并将其添加到我的路径中时:

/home/pragone/.rvm/gems/ruby-1.9.3-p125/bin
/home/pragone/.rvm/gems/ruby-1.9.3-p125/gems

我已经尝试重新运行〜/ .rvm / scripts / rvm,但它似乎没有为我的PATH添加正确的路径。我也做了一些工作安装(我的macbook pro,运行os x 10.7),并验证〜/ .rvm / scripts / rvm在工作安装中将项目添加到我的PATH,但不是ubuntu box。

which rails:黑客路径:

$ which rails
/home/pragone/.rvm/gems/ruby-1.9.3-p125/bin/rails

which rails:新的路径:(没有回应;可能没找到)

$ which rails
$

2 个答案:

答案 0 :(得分:21)

似乎缺少的链接是

$ rvm use ruby-1.9.3-p125 --default

好像已经修好了。

PS:谢谢你看这个。为了你的娱乐,如果你还没有在HN上看到它(它是蟒蛇,但仍然是一个很好的笑声):https://gist.github.com/289467

答案 1 :(得分:0)

试试这个,它对我有用:

  

gem update --system