尽管在列表中,Ruby无法找到宝石。

4

我遇到了一个奇怪的问题,当我尝试运行vagrant up时,系统突然找不到json gem。当我运行vagrant up时,会出现以下消息:

/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find  json (~> 1.5.1) amongst [Platform-0.4.0, archive-tar-minitar-0.5.2, builder-3.0.0,  bundler-1.1.5, childprocess-0.3.5, cucumber-1.2.1, diff-lcs-1.1.3, erubis-2.7.0, ffi-1.1.5, gemcutter-0.7.1, gherkin-2.11.2, git-1.2.5, hiera-0.3.0, hiera-json-0.3.0, hiera-puppet-0.3.0, highline-1.6.13, i18n-0.6.0, json-1.7.5, log4r-1.1.10, metaclass-0.0.1, mocha-0.12.3, net-scp-1.0.4, net-ssh-2.5.2, open4-1.3.0, popen4-0.1.2, progressbar-0.11.0, puppet-module-0.3.4, puppetlabs_spec_helper-0.3.0, rake-0.9.2.2, rspec-2.11.0, rspec-core-2.11.1, rspec-expectations-2.11.2, rspec-mocks-2.11.2, rspec-puppet-0.1.4, thor-0.16.0, vagrant-1.0.3, veewee-0.2.3, virtualbox-0.9.2] (Gem::LoadError)
        from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:771:in `activate_dependencies'
        from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `each'
        from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:760:in `activate_dependencies'
        from /usr/lib/ruby/vendor_ruby/1.8/rubygems/specification.rb:744:in `activate'
        from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1209:in `gem'
        from /usr/local/bin/vagrant:18

如您在上面的错误中所见,json gem 明显在列表中,但它无法识别。我已经搜索了这个问题并找到了很多情况,但大多数时候 gem 不在列表中。我没有多次安装 ruby,而且 gem 路径已设置。

gem env

RubyGems 环境:

  • RUBYGEMS版本: 1.8.15
  • RUBY版本: 1.8.7(2011年06月30日 patchlevel 352)[x86_64-linux]
  • 安装目录: /var/lib/gems/1.8
  • RUBY可执行文件: /usr/bin/ruby1.8
  • 可执行文件目录: /usr/local/bin
  • RUBYGEMS平台:
    • ruby
    • x86_64-linux
  • GEM路径:
    • /var/lib/gems/1.8
    • /home/adrian/.gem/ruby/1.8
  • GEM配置:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • 远程源:

这些安装目录是Ubuntu 12.04的默认设置。

宝石清单

* 本地宝石 *

archive-tar-minitar (0.5.2)
builder (3.0.0)
bundler (1.1.5)
childprocess (0.3.5)
cucumber (1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
ffi (1.1.5)
gemcutter (0.7.1)
gherkin (2.11.2)
git (1.2.5)
hiera (0.3.0)
hiera-json (0.3.0)
hiera-puppet (0.3.0)
highline (1.6.13)
i18n (0.6.0)
json (1.7.5)
log4r (1.1.10)
metaclass (0.0.1)
mocha (0.12.3)
net-scp (1.0.4)
net-ssh (2.5.2)
open4 (1.3.0)
Platform (0.4.0)
popen4 (0.1.2)
progressbar (0.11.0)
puppet-module (0.3.4)
puppetlabs_spec_helper (0.3.0)
rake (0.9.2.2)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
rspec-mocks (2.11.2)
rspec-puppet (0.1.4)
thor (0.16.0)
vagrant (1.0.3)
veewee (0.2.3)
virtualbox (0.9.2)

正如您所看到的,宝石也在此处的已安装列表中。环境变量$GEM_HOME$GEM_PATH未设置。

我一直在尝试解决这个问题,但目前还无法解决。非常感谢Ruby和/或Vagrant专家的任何帮助。

1个回答

4

正如你在这里指出的那样,你已经安装了json gem版本1.7.5。但是你收到的错误信息显示Could not find json (~> 1.5.1)~>语法意味着只有1.5.x版本是可接受的!因此,你需要安装其中一个以满足依赖关系。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接