安装 ruby gems 后,运行新 gem 会返回“找不到”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9622467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
After installing ruby gems, running the new gem returns "Could not find" errors
提问by eragone
Fresh Ubuntu 10.04 install:
全新 Ubuntu 10.04 安装:
I'm having some trouble getting my gem install process to play nicely. Any time I install a gem, it goes through a nice, straightforward process with no problems:
我在让我的 gem 安装过程正常运行时遇到了一些麻烦。任何时候我安装 gem 时,它都会经历一个很好的、简单的过程,没有任何问题:
$ gem install rails
Successfully installed rails-3.2.2
1 gem installed
And then to verify the version, perhaps a simple "rails -v"? Nope:
然后验证版本,也许是一个简单的“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>'
So let's make sure railties is installed:
因此,让我们确保安装了 railties:
$ gem install railties
Successfully installed railties-3.2.2
1 gem installed
And try to get the version of rails again:
并尝试再次获取 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>'
This happens with nearly every gem I install. I tried searching for some sort of documentation of how things are installed with gem, but couldn't find anything. It seems as though some gems are installed in one location, and some in another, and one of those locations is not in my path. Any ideas what's going on here?
我安装的几乎每个 gem 都会发生这种情况。我尝试搜索有关如何使用 gem 安装事物的某种文档,但找不到任何内容。似乎有些 gem 安装在一个位置,有些安装在另一个位置,其中一个位置不在我的路径中。任何想法这里发生了什么?
EDIT: Requested information:
编辑:请求的信息:
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/
And rvm info:
和 rvm 信息:
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 <[email protected]>, Michal Papis <[email protected]> [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: ""
Additionally, with the above listed PATH, I get this when trying to run rails:
此外,使用上面列出的 PATH,我在尝试运行 rails 时得到了这个:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
However, the aforementioned errors occurred when I was hacking around and added these to my PATH:
但是,上述错误发生在我四处走动并将这些添加到我的 PATH 中时:
/home/pragone/.rvm/gems/ruby-1.9.3-p125/bin
/home/pragone/.rvm/gems/ruby-1.9.3-p125/gems
I've tried re-running ~/.rvm/scripts/rvm, but it doesn't seem like it's adding the correct paths to my PATH. I've also done some picking around on a working-install (my macbook pro, running os x 10.7), and verified that ~/.rvm/scripts/rvm is adding items to my PATH in the working install, but not on the ubuntu box.
我试过重新运行 ~/.rvm/scripts/rvm,但它似乎没有向我的 PATH 添加正确的路径。我还对工作安装(我的 macbook pro,运行 os x 10.7)进行了一些挑选,并验证 ~/.rvm/scripts/rvm 在工作安装中向我的 PATH 添加项目,但不是在ubuntu 盒子。
which rails: Hacked PATH:
which rails:黑客路径:
$ which rails
/home/pragone/.rvm/gems/ruby-1.9.3-p125/bin/rails
which rails: fresh PATH: (no response; presumably not found)
which rails:新路径:(无响应;大概没有找到)
$ which rails
$
回答by eragone
Seems the missing link was
似乎缺少的链接是
$ rvm use ruby-1.9.3-p125 --default
Seems to have fixed it.
好像修好了。
PS: Thanks for looking at this. For your entertainment, if you didn't see it on HN yet (it's python, but still a good chuckle): https://gist.github.com/289467
PS:谢谢你看这个。为了你的娱乐,如果你还没有在 HN 上看到它(它是 python,但仍然是一个很好的笑声):https: //gist.github.com/289467
回答by liaojinxing
Try this, it works for me:
试试这个,它对我有用:
gem update --system
宝石更新--系统

