Carrierwave、MiniMagick - NoMethodError: nil:NilClass の未定義メソッド「size」 質問する

Carrierwave、MiniMagick - NoMethodError: nil:NilClass の未定義メソッド「size」 質問する

ステージングでは、carrierwave と minimagick を介して画像をアップロードしてサイズ変更するときに次のエラーが発生します。ローカルではすべて正常に動作します。

キャリアウェーブ (0.9.0) mini_magick (3.7.0)

irb(main):003:0> PicturePost.create(remote_content_url: 'http://www.imagpress.com/img/slider/slider_1.jpg')
NoMethodError: undefined method `size' for nil:NilClass
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick.rb:24:in `choose_processor'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick.rb:64:in `mogrify?'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:360:in `run_command'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:171:in `valid?'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:140:in `create'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:48:in `read'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:111:in `block in open'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/processing/mini_magick.rb:260:in `manipulate!'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/processing/mini_magick.rb:176:in `resize_to_fill'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/processing.rb:85:in `block in process!'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/processing.rb:81:in `each'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/processing.rb:81:in `process!'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/callbacks.rb:18:in `each'
9 levels...
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/download.rb:65:in `download!'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/mount.rb:353:in `remote_url='
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/mount.rb:203:in `remote_content_url='
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/orm/activerecord.rb:44:in `remote_content_url='
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:78:in `each'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/base.rb:498:in `initialize'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/persistence.rb:44:in `new'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/persistence.rb:44:in `create'
from (irb):3
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/railties-3.2.15/lib/rails/commands/console.rb:47:in `start'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/railties-3.2.15/lib/rails/commands/console.rb:8:in `start'
from /home/deploy/apps/staging/blog/shared/bundle/ruby/1.9.1/gems/railties-3.2.15/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'

なぜこのようなことが起こるのか分かりません。

ベストアンサー1

新しいサーバーにimagemagickをインストールするのを忘れていました。これで問題は解決しました

sudo apt-get install imagemagick

おすすめ記事