[英]Can't activate gem: how do I figure out which gem has a dependency on this one?
我收到以下错误:
Gem::Exception: can't activate hpricot (= 0.6.161, runtime),
already activated hpricot-0.8.3
在本地安装了0.6,在我的应用中冻结了0.8.3。
这是我的“ 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
如何确定哪个gem或库对hpricot 0.6有依赖性?
我在下面添加了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"=>[]}
如果使用Bundler,则可以避免此问题,并且您将拥有非常棒的命令: bundle viz
该命令生成具有所有依赖关系的图。
require 'rubygems'
require 'pp'
h = {}
Gem.source_index.each{|g, spec| h[g] = spec.dependencies.map{|d| d.name} }
pp h
我发现rfeedparser是使用hpricot 0.6的宝石。
问题在于该版本(0.6)可与rfeedparser一起使用,但发出警告“不推荐将参数不传递给XML :: SaxParser.new”。
好吧,对于较新版本的hpricot(至少为0.8.2),此警告似乎已经生效,因为现在使用该版本的hpricot或更高版本会导致在调用FeedParser时出现“ ArgumentError:错误的参数数量(1表示0)”。解析(URL)。
不幸的是,我发现使它与旧版Rails(我们有一个2.2.2应用程序)一起工作的唯一方法是卸载所有非0.6的hpricot版本。
问题是您使用的宝石之一取决于hpricot版本0.6.161,因此尝试加载它,但是您已经加载了hpricot-0.8.3。 如果您自己使用hpricot,则可能会加载较新的版本,并且需要使用hpricot而不指定版本。 在这种情况下,您可以将自己的要求更改为与其他gem使用的版本相同(0.6.161)。
加载较新版本的hpricot的另一个原因可能是,您使用的另一个gem取决于该版本的hpricot,这意味着您不能使用这两个gem的特定版本,因为它们的hpricot有冲突的要求版。
使用其他用户发布的方法来帮助您跟踪所使用的gem的依赖性。
您可以尝试grep加载路径:
$:.each do |dir|
cmd = %(grep -r hpricot #{dir})
puts cmd
puts `#{cmd}`
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.