RMagick errors when running Rake Tasks in OS X Maverick

We were running into some issues at work so I decided to pitch in. I had trouble listing my rake tasks as my rake tasks was spitting out this error through RMagick – Reason: image not found – /rmagick-2.13.2/RMagic2.bundle.

The full error was:

rake aborted!
LoadError: dlopen(/Users/kelvin/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-13/2.1.0/rmagick-2.13.2/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libMagickCore-6.Q16.1.dylib
 Referenced from: /Users/kelvin/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-13/2.1.0/rmagick-2.13.2/RMagick2.bundle
 Reason: image not found - /Users/kelvin/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-13/2.1.0/rmagick-2.13.2/RMagick2.bundle

Oddly enough, rmagick seemed to be installed properly and even after uninstalling both imagemagick through HomeBrew and rmagick through gem install, I still couldn’t run my rake task.Β After trying a few things like running gem pristine rmagick, I found myself on this blog instead. And it worked like a charm. The steps I took were:

brew install libtool --universal
brew link libtool
brew unlink libtool && brew link libtool
gem uninstall rmagick
gem install rmagick

That seem to do the trick for me. You could shorten the step to check to see if you had libtool installed already and then just tried the unlink and relinking.

  • Yeong Sheng Tan

    That did not work for me. I’m on Mac OSX 10.9 (Mavericks) with rvm 1.25.22 installed with ruby ruby-2.0.0-p353 with Homebrew package manager version 0.9.5

    These are the steps I took:

    `brew uninstall imagemagick`
    `brew uninstall libpng`
    `brew cleanup`
    `brew doctor`

    follow instructions from `brew doctor` to link/unlink or install any missing dependencies if needed

    `brew install imagemagick` (imagemagick 6.8.8-9 installed)
    `brew install libpng` (libpng 1.6.10 installed)

    Goto dir where you have your project and gemset, and,
    either remove ‘rmagick’ from Gemfile, followed by
    `bundle clean --force`
    `gem uninstall rmagick`

    either add back ‘rmagick’ gem to your Gemfile, followed by
    `bundle install`
    `gem install rmagick`
    (which should install rmagick 2.13.2 successfully)

    Goto your gemset dir that contains rmagick 2.13.2 dir (in my case ~/.rvm/ gems/[email protected]/extensions/x86_64-darwin-13/2.0.0/rmagick-2.13.2) and delete that dir (i.e. ~/.rvm/ gems/[email protected]/extensions/x86_64-darwin-13/2.0.0/rmagick-2.13.2)

    Repeat `bundle install` or `gem install rmagick`

    All good and done after that.

    • Hi Yeong Sheng,

      Thank you for sharing! As I mentioned, I found a number of different posts as well and shared what worked for me. I’ll update my post to add your steps as well. I’m sure other people who are stuck would appreciate any help that they can get!

      • Yeong Sheng Tan

        Agree. None of those posts exactly and directly fixed my issue. I guess everyone will have nuances to the problems/issues faced, and I thought my contribution will add value to the broader community.

  • Hi Kelvin,nnThank you for your post. To me I needed find my MagickWand.h and install rmagick included this path.nnmdfind MagickWand.hnnC_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.9-1/include/ImageMagick-6/ gem install rmagicknnnnAnd then works πŸ˜‰

  • Jonathan Kirst

    This did it for me! Like you said, found lots of different answers online, which is interesting in itself, but for whatever reason `brew unlink libtool && brew link libtool` was the trick for me. Thanks!

  • Dmitri

    This worked for me!

  • Adam

    Awesome! This helped me from endless head banging.

  • Pingback: rmagick libMagickCore.5.dylib (LoadError) – γ›γ‚“γΉγ„γ£γ¦ηΎŽε‘³γ—γ„γ‚ˆγ­()