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
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.
Doing a gem install rmagick
as a privileged user fixed the issue for me.
Not really a helpful solution, but I guess in my case I didn't actually have RMagick installed properly, even though bundler thought I did.
精彩评论