全新的Ubuntu 10.04安装:
我在安装gem时遇到了一些问题。无论何时我安装一个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>'
所以让我们确保已安装了railties:
$ 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 都会发生这种情况。我尝试搜索关于 gem 安装方式的文档,但没有找到任何信息。似乎某些 gem 安装在一个位置,而另一些 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: ""
除此之外,使用上面列出的路径时,我尝试运行rails时会得到以下结果:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
然而,当我尝试将以下内容添加到我的PATH时,出现了上述错误:
/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盒子上没有。
which rails
:被篡改的PATH:
$ which rails
/home/pragone/.rvm/gems/ruby-1.9.3-p125/bin/rails
which rails
: 当前 PATH:(无响应;可能未找到)
$ which rails
$
gem env
和rvm info
- mpapisrvm 1.9.3
,这应该设置你使用rvm的Ruby版本。然后再次运行gem install rails
。 - matt