Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rmagick won't find imagemagick on the server

I'm deploying a railsapp to ubuntu

rmagick is installed via "bundle install vendor". it installs , and the app runs -- but this error gets thrown :

uninitialized constant Image::Magick

when trying to read:

source_image = Magick::Image.read("#{Rails.root}/public/system/assets/#{self.id}/original/#{self.asset_file_name}").first

I've done the following:

  • uninstsalled, then reinstalled, ImageMagick on the server
  • uninstalled, then reinstalled, rmagick on the server
  • uninstalled, then reinstalled, rmagick via bundler
  • run with only the bundler rmagick installed
  • run with the bundler and system rmagick installed
  • proxied nginx to rails-server to ensure the error is not related to passenger

I'm going a bit crazy trying to figure out what else I can do to make rmagick see imagemagick

like image 650
Jonathan Vanasco Avatar asked Dec 22 '10 21:12

Jonathan Vanasco


1 Answers

After hours of fighting and recompiling imagemagick and rmagick under different combinations, I lucked out on a 1 line fix

Gemfile

- gem 'rmagick'
+ gem 'rmagick', :require => 'RMagick'

Bundler requires the gem name by default,

i.e. :require => 'rmagick'.

But the file being included is actually 'RMagick.rb'. For case-insensitive file systems, like OS X, this will work, but for case-sensitive file systems, like Ubuntu, the file will not be found.

This can be one of the reasons why the error can't be produced on the dev system, even when running in production mode.

like image 72
Jonathan Vanasco Avatar answered Oct 14 '22 18:10

Jonathan Vanasco