简体   繁体   English

无法激活gem:如何确定哪个gem依赖于此gem?

[英]Can't activate gem: how do I figure out which gem has a dependency on this one?

I'm getting the following error: 我收到以下错误:

Gem::Exception: can't activate hpricot (= 0.6.161, runtime), 
already activated hpricot-0.8.3

0.6 is installed locally, 0.8.3 is frozen in my app. 在本地安装了0.6,在我的应用中冻结了0.8.3。

This is my "stacktrace": 这是我的“ stacktrace”:

Loading production environment (Rails 2.3.10)
/software/ruby-ror-gem-1.3.1/lib/rubygems.rb:149:in `activate':Gem::Exception: can't activate hpricot (= 0.6.161, runtime), already activated hpricot-0.8.3
/e/app/www.example.com/rails/releases/20101117142713/vendor/rails/railties/lib/console_with_helpers.rb:5:NameError: uninitialized constant ApplicationController

How do I figure out which gem or library has a dependency on hpricot 0.6? 如何确定哪个gem或库对hpricot 0.6有依赖性?


I've added the output of user438962's command below: 我在下面添加了user438962的命令的输出:

{"daemons-1.0.9"=>[],
 "scgi_dp_rails-0.0.5"=>["preforkdp", "daemons"],
 "rails-2.3.10"=>[],
 "rwfd-0.1.0"=>[],
 "nokogiri-1.3.2"=>["racc", "rexical", "rake-compiler", "hoe"],
 "activesupport-2.3.10"=>[],
 "rack-1.0.1"=>
  ["test-spec",
   "camping",
   "fcgi",
   "memcache-client",
   "mongrel",
   "ruby-openid",
   "thin"],
 "rack-1.1.0"=>
  ["test-spec", "camping", "fcgi", "memcache-client", "mongrel", "thin"],
 "preforkdp-0.1.2"=>["rwfd"],
 "activerecord-2.3.10"=>[],
 "hpricot-0.6.161"=>[],
 "cgi_multipart_eof_fix-2.5.0"=>[],
 "fastthread-1.0.1"=>[],
 "gem_plugin-0.2.3"=>[],
 "activeresource-2.3.10"=>[],
 "ferret-0.11.6"=>["rake"],
 "mysql-2.7"=>[],
 "actionmailer-2.3.10"=>[],
 "actionpack-2.3.10"=>[],
 "hpricot-0.8.3"=>[],
 "mongrel_upload_progress-0.2.2"=>["mongrel", "gem_plugin"],
 "mongrel-1.1.3"=>
  ["gem_plugin", "daemons", "fastthread", "cgi_multipart_eof_fix"],
 "mongrel_cluster-1.0.5"=>["gem_plugin", "mongrel"],
 "rake-0.8.4"=>[],
 "haml-2.0.9"=>[],
 "remvee-mini_magick-1.2.3.4.0"=>[]}

If you use Bundler, you avoid this problem and you have the really great command : bundle viz 如果使用Bundler,则可以避免此问题,并且您将拥有非常棒的命令: bundle viz

This Command generate a graph with all dependencies. 该命令生成具有所有依赖关系的图。

require 'rubygems'
require 'pp'
h = {}
Gem.source_index.each{|g, spec| h[g] = spec.dependencies.map{|d| d.name} }
pp h

I found that rfeedparser is the gem that uses hpricot 0.6. 我发现rfeedparser是使用hpricot 0.6的宝石。

The problem is that this version (0.6) works with rfeedparser, but emits the warning "Passing no parameters to XML::SaxParser.new is deprecated." 问题在于该版本(0.6)可与rfeedparser一起使用,但发出警告“不推荐将参数不传递给XML :: SaxParser.new”。

Well, with newer versions of hpricot (at least 0.8.2), this warning seems to have taken effect, because now having that version of hpricot or newer causes "ArgumentError: wrong number of arguments (1 for 0)" when calling FeedParser.parse(url). 好吧,对于较新版本的hpricot(至少为0.8.2),此警告似乎已经生效,因为现在使用该版本的hpricot或更高版本会导致在调用FeedParser时出现“ ArgumentError:错误的参数数量(1表示0)”。解析(URL)。

Unfortunately, I've found that the only way to make this work with legacy Rails (we have a 2.2.2 app) is to uninstall any hpricot version that's not 0.6. 不幸的是,我发现使它与旧版Rails(我们有一个2.2.2应用程序)一起工作的唯一方法是卸载所有非0.6的hpricot版本。

The issue will be that one of the gems you use depends on hpricot version 0.6.161 and so tries to load it, but that you already have hpricot-0.8.3 loaded. 问题是您使用的宝石之一取决于hpricot版本0.6.161,因此尝试加载它,但是您已经加载了hpricot-0.8.3。 The more recent version might be loaded if you're using hpricot yourself, and have required hpricot for use without specifying a version. 如果您自己使用hpricot,则可能会加载较新的版本,并且需要使用hpricot而不指定版本。 If that's the case, you can change your own require to be the same version as the other gem uses (0.6.161). 在这种情况下,您可以将自己的要求更改为与其他gem使用的版本相同(0.6.161)。

The other reason the more recent version of hpricot is being loaded, could be that another gem you use depends on that version of hpricot, meaning you can't use the specific versions of those two gems you have because they have clashing requirements for their hpricot version. 加载较新版本的hpricot的另一个原因可能是,您使用的另一个gem取决于该版本的hpricot,这意味着您不能使用这两个gem的特定版本,因为它们的hpricot有冲突的要求版。

Use the methods other users have posted to help you track down the dependencies of the gems you are using. 使用其他用户发布的方法来帮助您跟踪所使用的gem的依赖性。

You could try grepping your load path: 您可以尝试grep加载路径:

$:.each do |dir|
  cmd = %(grep -r hpricot #{dir})
  puts cmd
  puts `#{cmd}`
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何找出哪个 gem 具有特定的依赖关系? - How do I find out which gem has a specific dependency? 我如何找出导致特定宝石捆绑在一起的宝石? - How do I figure out which gem(s) caused a particular gem to be bundled? 如何找出哪个Ruby gem劫持了ActiveRecord关联方法 - How to figure out which Ruby gem has hijacked an ActiveRecord association method 在本地项目目录中安装 gem 时,如何确定正确的 gem 文件路径应该是什么? - When installing a gem in a local project directory, how do I figure out what the proper gem file path should be? 无法弄清楚如何使用devise_token_auth gem更新用户 - Can't figure out how to update users with devise_token_auth gem 我如何从 jquery-ui-rails gem 版本中找出 JQuery UI 的版本? - How do i figure out the version of JQuery UI from version of jquery-ui-rails gem? 如何“激活”特定宝石的不同版本? - How do I “activate” a different version of a particular gem? Rails 5:我如何找出哪个 Gem 取决于特定的 Ruby 版本? - Rails 5: How Do I Find Out Which Gem Depends on a Specific Ruby Version? 如何在 Rails 3(捆绑器)中解决这个 gem 依赖问题? - How do I fix this gem dependency problem in Rails 3 (bundler)? 找出哪个 gem 正在请求 rb-inotify - Figure out which gem is requesting rb-inotify
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM