2010-09-23 57 views
0

我剛剛創建了一個簡單的遷移到現有的項目。本項目採用RMagick,當我叫耙分貝:遷移遷移從而失敗:rake db:遷移失敗:尋找RMagick - 爲什麼?

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?這個問題的解決方法是什麼?我使用Rails 2.2.2 OS X 10.6,這裏是當地的寶石列表:

*當地的寶石*

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) 

回答

-1

執行Rake任務(例如執行數據庫遷移幷包含gem依賴項)時會加載整個Rails環境。當我復活一箇舊項目時,我最近被同樣的東西咬了,直到我安裝了某些無關的寶石,我才遷移數據庫。

從查看堆棧跟蹤(Library not loaded: /usr/local/libpng/lib/libpng12.0.dylib)中的信息,我懷疑ImageMagick未在您的計算機上正確安裝。你可能想試試this script

+0

當應用程序運行時整個Rails環境不會被加載嗎?它運行沒有問題,但它死於rake db:migrate。解決方法:在遷移時禁用對environment.rb中rmagick的引用... – 2010-09-24 21:55:53

+0

指向腳本的鏈接已中斷。 – 2013-06-18 16:08:10

0

我不知道爲什麼你的機器沒有找到它,但Rails中的rake任務需要您的應用程序配置爲使用的任何gem,即使代碼未被調用。

如果沒有,則可能會發生其他一些呼叫(即由缺失的寶石覆蓋)並導致意外行爲。