rake db:migrate失败:寻找RMagick - 为什么?

时间:2010-09-23 13:32:59

标签: ruby-on-rails migration rmagick

我刚刚创建了一个简单的迁移到现有项目。这个项目使用RMagick,当我调用rake db:migrate时,迁移失败了:

Dans-iMac-335:myserver apple$ rake db:migrate
(in /Users/apple/Documents/projects/electionjoy/glowing-mist-78)
dlopen(/Users/apple/.gem/ruby/1.8/gems/rmagick-2.12.1/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/libpng/lib/libpng12.0.dylib
  Referenced from: /Users/apple/.gem/ruby/1.8/gems/rmagick-2.12.1/lib/RMagick2.bundle
  Reason: image not found - /Users/apple/.gem/ruby/1.8/gems/rmagick-2.12.1/lib/RMagick2.bundle
/Users/apple/.gem/ruby/1.8/gems/rmagick-2.12.1/lib/RMagick2.bundle
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/Users/apple/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
/Users/apple/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/apple/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
/Users/apple/.gem/ruby/1.8/gems/rmagick-2.12.1/lib/RMagick.rb:11

还有更多,但这是它寻找RMagick的地方。该捆绑存在于该位置。

为什么数据库迁移需要RMagick gem存在?这个问题的解决方案是什么?我在OS X 10.6上使用Rails 2.2.2,这是本地gem列表:

*本地宝石*

actionmailer (2.3.8, 2.3.5, 2.2.2)
actionpack (2.3.8, 2.3.5, 2.2.2)
actionwebservice (1.2.3)
activemerchant (1.5.1)
activerecord (2.3.8, 2.3.5, 2.2.2)
activerecord-tableless (0.1.0)
activeresource (2.3.8, 2.3.5, 2.3.3, 2.2.2)
activesupport (2.3.8, 2.3.5, 2.3.3, 2.2.2)
authlogic (2.1.5)
authlogic-oid (1.0.4)
aws-s3 (0.6.2)
builder (2.1.2)
capistrano (2.5.9)
cgi_multipart_eof_fix (2.5.0)
chronic (0.2.3)
configuration (1.1.0)
daemons (1.0.10)
facebooker (1.0.62)
faker (0.3.1)
fastthread (1.0.7)
gem_plugin (0.2.3)
google-geocode (1.2.1)
heroku (1.8.5, 1.3.0, 1.0.1)
highline (1.5.1)
hoe (2.3.3)
hpricot (0.8.1)
json (1.1.9)
json_pure (1.2.4, 1.1.9)
launchy (0.3.3)
less (1.2.20)
libxml-ruby (1.1.3)
mime-types (1.16)
minitest (1.4.2)
mongrel (1.1.5)
mutter (0.5.3)
mysql (2.8.1)
net-scp (1.0.2)
net-sftp (2.0.2)
net-ssh (2.0.15)
net-ssh-gateway (1.0.1)
nokogiri (1.3.3)
packet (0.1.15)
paperclip (2.3.1.1)
passenger (2.2.5)
pg (0.9.0, 0.8.0)
polyglot (0.3.1)
postgres (0.7.9.2008.01.28)
rack (1.1.0, 1.0.1, 1.0.0)
radiant (0.8.1)
rails (2.3.8, 2.3.5, 2.2.2)
rake (0.8.7)
rc-rest (3.0.0)
RedCloth (4.2.3)
rest-client (1.3.1, 1.0.3)
rmagick (2.13.1, 2.12.1)
ruby-openid (2.1.7)
rubyforge (2.0.4, 2.0.2)
rubygems-update (1.3.7, 1.3.5)
searchlogic (2.3.5)
sequel (3.0.0)
sinatra (0.9.2)
spree (0.10.2)
sqlite3-ruby (1.2.5, 1.0.1)
state_machine (0.8.0)
stringex (1.0.3)
taps (0.2.26, 0.2.19)
thor (0.9.9)
treetop (1.4.8)
whenever (0.3.7)
will_paginate (2.3.11)
xml-simple (1.0.12)

2 个答案:

答案 0 :(得分:0)

我不知道为什么你的机器没有找到它,但是rails中的rake任务需要你的app配置使用的任何gem,即使代码没有被调用。

如果没有,则可能会发生其他一些调用(被缺少的宝石覆盖)并导致意外行为。

答案 1 :(得分:-1)

执行Rake任务(例如执行数据库迁移并包含gem依赖项)时会加载整个Rails环境。最近在复活旧项目时我被同样的事情所困扰,在我安装了某些不相关的宝石之前我无法迁移数据库。

通过查看堆栈跟踪(Library not loaded: /usr/local/libpng/lib/libpng12.0.dylib)中的信息,我怀疑您的计算机上没有正确安装ImageMagick。您可能想尝试this script