【问题标题】:My attempts to install json using "gem install json" don't seem to be working我尝试使用“gem install json”安装 json 似乎不起作用
【发布时间】:2014-08-12 16:23:40
【问题描述】:

当我尝试运行脚本来设置我的工作区时,我收到了这个错误

/opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find json (<= 1.6.1, >= 1.4.4) amongst [bigdecimal-1.1.0, bundler-1.1.5, bunny-0.7.9, chef-10.14.4, erubis-2.7.0, highline-1.6.15, io-console-0.3, ipaddress-0.8.0, jruby-pageant-1.1.1, json-1.8.1, mime-types-1.19, minitest-2.5.1, mixlib-authentication-1.3.0, mixlib-cli-1.2.2, mixlib-config-1.1.2, mixlib-log-1.4.1, mixlib-shellout-1.1.0, moneta-0.6.0, net-ssh-2.2.2, net-ssh-gateway-1.1.0, net-ssh-multi-1.1, ohai-6.14.0, polyglot-0.3.3, rake-0.9.2.2, rdoc-3.9.4, rest-client-1.6.7, systemu-2.5.2, treetop-1.4.10, uuidtools-2.1.3, yajl-ruby-1.1.0] (Gem::LoadError)
    from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:777:in `block in activate_dependencies'
    from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems.rb:1232:in `gem'
    from /opt/chef/bin/chef-solo:22:in `<main>'
you have a different version of chef installed and we don't support uninstalling them with this script, we only support version 10.14.4

我假设这意味着我需要 1.4.4 和 1.6.1 之间的 json 版本,所以我运行了这个语句

gem install json -v 1.6.1

这吐出来了....

WARNING:  Error fetching data: Errno::ETIMEDOUT: Operation timed out - connect(2) (https://gem.vistacore.us:8443/gem/specs.4.8.gz)
WARNING:  Error fetching data: Errno::ETIMEDOUT: Operation timed out - connect(2) (https://nexus.vistacore.us:8443/gem/specs.4.8.gz)
Fetching: json-1.6.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed json-1.6.1
1 gem installed
Installing ri documentation for json-1.6.1...
Installing RDoc documentation for json-1.6.1...

但是当我尝试重新运行我的工作区脚本时,我又遇到了第一个错误。就好像什么都没有安装一样。这是怎么回事?

谢谢!

【问题讨论】:

  • 你的Gemfile 中有json gem 吗?
  • 我没有 GemFile 目录,但我有一堆 GemFile,打开它们显示其中一些具有 json 1.8.1,而另一些似乎没有。跨度>
  • require "json"了吗?
  • 您能否运行ruby -vwhich ruby 并将输出粘贴到此处?
  • @sethvargo 我不确定你所说的 require "json" 是什么意思

标签: ruby-on-rails ruby json rubygems chef-infra


【解决方案1】:

来自实际的错误

您安装了不同版本的 chef,我们不支持使用此脚本卸载它们,我们仅支持版本 10.14.4

我会尝试卸载您的版本,然后使用 chef 10.14.4 安装

【讨论】:

    【解决方案2】:

    首先,让我们列出你所有的 ruby​​ 版本,因为你可能有多个版本

    $ rvm list ruby
    

    其次,还要检查您的 gem 版本,如果版本与您的程序想要的不匹配,则不要删除那些东西并放入它想要的版本或执行一个

    $ rvm use (foo)
    

    查看您的 gem 版本后

    $ gem --version
    

    检查你所有的环境变量,比如$GEM_HOME等等。

    有时会因为您的环境变量可能已关闭而错过本机扩展。在你修复所有这些之后,你会很好,只需安装 json gem。

    $ gem install json
    

    无需指定版本,它会自动拉取所需的版本。

    请记住,rubygem 根据自己的版本安装 gems,而您通过 rvm 安装的 ruby​​gem 版本基于 rvm 安装的 ruby​​ 版本,因此这一切都可以追溯到 ruby​​ 和 ruby​​gems rvm 安装在您机器上的版本您的安装时间。如果 ruby​​gem 和 ruby​​ 版本是正确的,那么它会在您安装它时自动拉取与您的程序兼容的 json gem,正确添加您的 env 变量有助于构建本机扩展并帮助您的程序查看所有内容。我希望这有助于阐明一些事情。

    【讨论】:

    • 无需在答案中不断更改您的姓名;它没有相关性。如果您想更改姓名,请更新您的个人资料名称。
    猜你喜欢
    • 1970-01-01
    • 2013-11-01
    • 1970-01-01
    • 2020-06-28
    • 2012-05-21
    • 1970-01-01
    • 2014-08-11
    • 1970-01-01
    相关资源
    最近更新 更多