更新系统后出现 RubyGems 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7786543/
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
RubyGems error after updating system
提问by Elliot
When trying to launch the rails console after updating my ruby setup using 'sudo gem update --system', I then try execute the rails console by issuing rails c
在使用“sudo gem update --system”更新我的 ruby 设置后尝试启动 rails 控制台时,我然后尝试通过发出以下命令来执行 rails 控制台 rails c
I get this error:
我收到此错误:
Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [Ascii85-1.0.1, abstract-1.0.0, actionmailer-3.1.1, actionmailer-3.1.0, actionmailer-3.0.9, actionmailer-3.0.5, actionmailer-3.0.3, actionpack-3.1.1, actionpack-3.1.0, actionpack-3.0.9, actionpack-3.0.5, actionpack-3.0.3, activemodel-3.1.1, activemodel-3.1.0, activemodel-3.0.10, activemodel-3.0.9, activemodel-3.0.5, activemodel-3.0.3, activerecord-3.1.1, activerecord-3.1.0, activerecord-3.0.9, activerecord-3.0.5, activerecord-3.0.3, activeresource-3.1.1, activeresource-3.1.0, activeresource-3.0.9, activeresource-3.0.5, activeresource-3.0.3, activesupport-3.1.1, activesupport-3.1.0, activesupport-3.0.10, activesupport-3.0.9, activesupport-3.0.5, activesupport-3.0.3, addressable-2.2.6, ansi-1.3.0, arel-2.2.1, arel-2.0.10, arel-2.0.9, arel-2.0.7, bcrypt-ruby-3.0.1, bcrypt-ruby-3.0.0, bcrypt-ruby-2.1.4, builder-3.0.0, builder-2.1.2, bundler-1.0.21, bundler-1.0.18, bundler-1.0.11, choices-0.2.4, cocaine-0.2.0, coffee-rails-3.1.1, coffee-rails-3.1.0, coffee-script-2.2.0, coffee-script-source-1.1.2, devise-1.4.8, devise-1.4.2, erubis-2.7.0, erubis-2.6.6, execjs-1.2.9, execjs-1.2.6, execjs-1.2.4, faraday-0.7.4, faraday-0.6.1, faraday_middleware-0.7.0, faraday_middleware-0.6.3, fastercsv-1.5.4, formtastic-2.0.2, formtastic-1.2.4, geocoder-1.0.4, geocoder-1.0.2, has_scope-0.5.1, hashie-1.1.0, hashie-1.0.0, heroku-2.7.0, hike-1.2.1, i18n-0.6.0, i18n-0.5.0, inherited_resources-1.3.0, inherited_resources-1.2.2, jquery-rails-1.0.16, jquery-rails-1.0.14, kaminari-0.12.4, launchy-2.0.5, libv8-3.3.10.2-x86_64-darwin-10, mail-2.3.0, mail-2.2.19, mail-2.2.15, mail-2.2.14, mechanize-2.0.1, mechanize-1.0.0, meta_search-1.1.1, meta_search-1.0.6, mime-types-1.16, multi_json-1.0.3, multi_xml-0.4.1, multi_xml-0.4.0, multi_xml-0.3.0, multi_xml-0.2.2, multipart-post-1.1.3, multipart-post-1.1.2, mysql-2.8.1, mysql2-0.3.7, mysql2-0.2.7, mysql2-0.2.6, net-http-digest_auth-1.1.1, net-http-persistent-2.1, net-http-persistent-2.0, net-http-persistent-1.9, nokogiri-1.5.0, nokogiri-1.4.4, orm_adapter-0.0.5, pdf-reader-0.10.0, pg-0.11.0, polyamorous-0.5.0, polyglot-0.3.2, polyglot-0.3.1, prawn-0.12.0, rack-1.3.4, rack-1.3.3, rack-1.3.2, rack-1.2.3, rack-1.2.2, rack-1.2.1, rack-cache-1.1, rack-cache-1.0.3, rack-mount-0.8.3, rack-mount-0.6.14, rack-mount-0.6.13, rack-ssl-1.3.2, rack-test-0.6.1, rack-test-0.5.7, rails-3.1.1, rails-3.1.0, rails-3.0.9, rails-3.0.5, rails-3.0.3, railties-3.1.1, railties-3.1.0, railties-3.0.9, railties-3.0.5, railties-3.0.3, rake-0.9.2, rake-0.8.7, rake-0.8.7, rash-0.3.1, rash-0.3.0, rdoc-3.10, rdoc-3.9.4, rdoc-3.9.2, responders-0.6.4, rest-client-1.6.7, rubygems-update-1.8.11, rubygems-update-1.8.10, rubygems-update-1.7.2, rubygems-update-1.7.1, rubygems-update-1.6.2, rubyzip-0.9.4, sass-3.1.10, sass-3.1.7, sass-rails-3.1.4, sass-rails-3.1.2, sass-rails-3.1.0, simple_oauth-0.1.5, sprockets-2.0.2, sprockets-2.0.0, sqlite3-1.3.4, term-ansicolor-1.0.6, therubyracer-0.9.4, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, treetop-1.4.9, ttfunk-1.0.3, ttfunk-1.0.2, turn-0.8.2, twitter-1.7.1, twitter-1.4.1, tzinfo-0.3.30, tzinfo-0.3.29, tzinfo-0.3.26, tzinfo-0.3.24, uglifier-1.0.3, warden-1.0.6, warden-1.0.5, webrobots-0.0.12, webrobots-0.0.11] (Gem::LoadError)
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1932:in `block in traverse'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1931:in `each'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1931:in `traverse'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:465:in `block in find_in_unresolved_tree'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:463:in `reverse_each'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:463:in `find_in_unresolved_tree'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:47:in `require'
from /Users/myusername/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.1.1/lib/rails/script_rails_loader.rb:1:in `<top (required)>'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/myusername/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.1.1/lib/rails/cli.rb:2:in `<top (required)>'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/myusername/.rvm/gems/ruby-1.9.2-p136/gems/rails-3.1.1/bin/rails:7:in `<top (required)>'
from /Users/myusername/.rvm/gems/ruby-1.9.2-p136/bin/rails:19:in `load'
from /Users/myusername/.rvm/gems/ruby-1.9.2-p136/bin/rails:19:in `<main>'
Any ideas?
有任何想法吗?
采纳答案by Tilo
what do you get when you try to list your gems.. is json >= 1.4 there?
当您尝试列出您的 gem 时,您会得到什么.. json >= 1.4 在那里吗?
e.g.:
例如:
> gem list json
*** LOCAL GEMS ***
json (1.6.1, 1.5.4, 1.5.3, 1.5.1, 1.4.2)
json_pure (1.6.1, 1.5.4, 1.5.3)
if you use RVM gemsets, you may want to list them also, to check if your default gemset has changed:
如果您使用 RVM gemset,您可能还想列出它们,以检查您的默认 gemset 是否已更改:
rvm gemset list
EDIT: Mystery Solved!:-)
编辑: 谜团解开!:-)
you accidentially installed your gems with sudo -- but you have RVM installed for your user account!
您不小心使用 sudo 安装了 gems——但是您为您的用户帐户安装了 RVM!
When you have RVM installed for an individual user, it's generally not a good idea to do sudo gem install ... , but you should install the gems just for the local user and let RVM manage them for whatever Ruby version you are using.
当您为单个用户安装了 RVM 时,执行 sudo gem install ... 通常不是一个好主意,但是您应该只为本地用户安装 gems,并让 RVM 为您使用的任何 Ruby 版本管理它们。
If you still install with sudo, RVM will not find the gems, because they are stored in a different location, outside of RVM, and not searched by RVM...! Looks like that's the case you experienced.
如果您仍然使用 sudo 安装,RVM 将找不到 gem,因为它们存储在不同的位置,位于 RVM 之外,并且不会被 RVM 搜索......!看来你遇到过这种情况。
Check this RailsCast: http://railscasts.com/episodes/200-rails-3-beta-and-rvm
检查这个 RailsCast:http://railscasts.com/episodes/200-rails-3-beta-and-rvm
if you're using Rails:
- edit your Gemfileand add the json dependency , then run bundle install
如果您使用 Rails: -编辑您的 Gemfile并添加 json 依赖项,然后运行bundle install
if you're just using Ruby by itself, or an old version or Ruby:
- run gem install jsonin the shell
如果您只是单独使用 Ruby,或者使用旧版本或 Ruby: -gem install json在 shell 中运行
With newer Ruby versions you should not manually install the gems
使用较新的 Ruby 版本,您不应手动安装 gems
回答by Ashley Williams
Add gem "json", "~> 1.4"in your Gemfile and run bundle install
添加gem "json", "~> 1.4"您的 Gemfile 并运行bundle install
回答by ddd
Also
还
You onlyuse the sudo command during the install process. In Multi-User configurations, any operations which require sudo access must use the rvmsudo command which preserves the RVM environment and passes this on to sudo. There are very few cases where rvmsudo is required once the core install is completed, except for when updating RVM itself. There is never a reason to use sudo post-install. Once users added to the 'rvm' group have logged out, then back in to gain rvm group membership, rvmsudo should only be needed for updating RVM itself with
您只能在安装过程中使用 sudo 命令。在多用户配置中,任何需要 sudo 访问的操作都必须使用 rvmsudo 命令,该命令会保留 RVM 环境并将其传递给 sudo。核心安装完成后,很少有需要 rvmsudo 的情况,除非更新 RVM 本身。永远没有理由在安装后使用 sudo。一旦添加到 'rvm' 组的用户退出,然后重新登录以获得 rvm 组成员身份,rvmsudo 应该只用于更新 RVM 本身
rvmsudo rvm get head
Pleaseread the https://rvm.beginrescueend.com/support/troubleshooting/page The installer page also details this for new installations. You will need to remove your existing installation and redo it in order to properly reconfigure the permissions. In the future, neveruser sudowhen working on your RVM installation, exceptwhen installing. Anyother commands will not require sudo use exceptfor
请阅读https://rvm.beginrescueend.com/support/troubleshooting/页面安装程序页面还详细介绍了新安装。您将需要删除现有安装并重做以正确重新配置权限。将来,在进行 RVM 安装时永远不要使用sudo,安装时除外。任何其他命令不需要须藤使用除用于
rvmsudo rvm get head
to update your installation. If the users are properly placed in the rvm group as detailed on the site, you will have no need to use sudo at all, and rvmsudo onlyfor updating.
更新您的安装。如果用户按照站点上的详细说明正确放置在 rvm 组中,则您根本不需要使用 sudo,而 rvmsudo仅用于更新。
Also, RVM does not manage the system installed ruby at all! We do provide the use of
此外,RVM不管理系统安装红宝石在所有!我们确实提供使用
rvm use system
in order to give a natural way to switch between RVM controlled rubies, and the system. Your package manager, or lack thereof for OS X, is responsible for managing your system installed ruby and is outside the control of RVM 100%.
为了提供一种在 RVM 控制的红宝石和系统之间切换的自然方式。您的包管理器(或 OS X 缺少包管理器)负责管理系统安装的 ruby,并且不受 RVM 100% 的控制。

