19

after running brew upgrade imagemagick, when I run rails s I'll get

/Users/tomi/.rvm/gems/ruby-2.0.0-p247@ezaaa/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': dlopen(/Users/tomi/.rvm/gems/ruby-2.0.0-p247@ezaaa/gems/rmagick-2.13.2/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libMagickCore.5.dylib (LoadError)
  Referenced from: /Users/tomi/.rvm/gems/ruby-2.0.0-p247@ezaaa/gems/rmagick-2.13.2/lib/RMagick2.bundle
  Reason: image not found - /Users/tomi/.rvm/gems/ruby-2.0.0-p247@ezaaa/gems/rmagick-2.13.2/lib/RMagick2.bundle

I'm using Carrierwave gem with RMagick, OS is OSX Moutain Lion

1
  • When brew upgrade imagemagick breaks rails, it usually just means your rmagick gem has to be upgraded to a newer version as well.
    – Yarin
    Jan 14, 2022 at 22:13

6 Answers 6

31

Anyone else struggling with this right now (Jan 2017) - RMagick 2.15.4 can't be built with ImageMagick 7.0.x

First, please do this:

brew uninstall ImageMagick
gem uninstall rmagick

Second, please see https://github.com/rmagick/rmagick/issues/256 and read the answer by hristozov, viz:

brew rm imagemagick
cd "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/"
git checkout 6f014f2b7f1f9e618fd5c0ae9c93befea671f8be imagemagick.rb
brew install imagemagick
brew pin imagemagick
git reset --hard

This will force homebrew to use /usr/local/Cellar/imagemagick/6.9.7-3

Third,

gem install rmagick
4
  • 1
    Yep. Jan 2017 and I was struggling with this. Thanks. It worked.
    – Jason R
    Jan 18, 2017 at 1:17
  • Yes, this worked also for me. The right steps should however be: 1. brew uninstall ImageMagick 2. gem uninstall rmagick (all versions) 3. <do the steps above to install the working version of ImageMagick> 4. gem install rmagick worked for me Jan 18, 2017 at 11:39
  • @AndreaSalicetti thanks I have incorporated your comments in the answer
    – PeteW
    Jan 19, 2017 at 7:56
  • Great stuff @PeteW! This is the only thing that worked for me after a day of issue <3
    – mokagio
    Jan 31, 2017 at 11:07
28

thx to bit unrelated answer found here I manage to fix this by:

1/ search for this lib in the system

sudo find / -name "libMagickCore.5.dylib" -print

I found mine in /usr/local/Cellar/imagemagick/6.7.7-6/lib/libMagickCore.5.dylib

2/ link this library to required path

ln /usr/local/Cellar/imagemagick/6.7.7-6/lib/libMagickCore.5.dylib /usr/local/lib/libMagickCore.5.dylib
1
  • 2
    similar problem fixed for libltdl.7.dylib ln /usr/local/Cellar/libtool/2.4.2/lib/libltdl.7.dylib /usr/local/lib/libltdl.7.dylib Jun 1, 2014 at 20:10
18

1 brew uninstall ImageMagick

2 brew install ImageMagick

3 gem uninstall rmagick (all versions)

4 gem install rmagick

worked for me

2
  • 1
    This works for me. It seems a proper solution than sudo symlinking some library file.
    – Zack Xu
    Jan 9, 2017 at 16:29
  • 1
    perfect, this worked for me in 2021 with Rails 5 so is still relevant. simplest solution to get a clean install of everything
    – FireDragon
    Mar 17, 2021 at 22:52
16

Just this helped me:

gem pristine rmagick

Thanks to https://github.com/mroth/lolcommits/issues/9#issuecomment-5153570

2
  • could be. Just to be aware: gem pristine XXXX is for reversing any changes developer done to locally installed gem. E.g. if you were debugging a locally installed gem and you forgot to remove binding.pry Aug 21, 2017 at 9:34
  • Thanks, man resolve the issue after this :) Jul 14, 2021 at 7:21
4

Big thanks! I had the same problem:

$ perl -le 'use Image::Magick'

Can't load '/Library/Perl/5.16/darwin-thread-multi-2level/auto/Image/Magick/Magick.bundle' for module Image::Magick: dlopen(/Library/Perl/5.16/darwin-thread-multi-2level/auto/Image/Magick/Magick.bundle, 1): Library not loaded: /usr/local/lib/libMagickCore-6.Q16.1.dylib
Referenced from: /Library/Perl/5.16/darwin-thread-multi-2level/auto/Image/Magick/Magick.bundle Reason: image not found at /System/Library/Perl/5.16/darwin-thread-multi-2level/DynaLoader.pm line 194. at -e line 1. Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1. &Image::Magick::constant not defined. The required ImageMagick libraries are not installed or not installed properly. END failed--call queue aborted at -e line 1.

And after:

$ sudo find / -name "libMagickCore-6.Q16.1.dylib" -print

/usr/local/Cellar/imagemagick/6.8.7-7/lib/libMagickCore-6.Q16.1.dylib

I created a symlink:

$ ln -s /usr/local/Cellar/imagemagick/6.8.7-7/lib/libMagickCore-6.Q16.1.dylib /usr/local/lib/libMagickCore-6.Q16.1.dylib

And removed and installed all the imagemagick dependences:

$ brew install perlmagick

==> Installing dependencies for perlmagick: libpng, imagemagick

And everything works now.

0

The issue was fixed for by running gem uninstall rmagick and gem install rmagick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.