ImageMagick 7 with RMagick 2.16 on MacOS Sierra Can't find MagickWand.h - ruby

I upgraded to imagemagick-7.0.4-3.sierra and now my previously installed RMagck 2.16 fails. I checked for MagicWand:
$ find /usr/local -name MagickWand.h
/usr/local/Cellar/imagemagick/7.0.4-3/include/ImageMagick-7/MagickWand/MagickWand.h
So it seems to be there. Also I reinstalled and relinked pgk-config. Didn't help as well. Any ideas?

I have just encountered and solved this issue on a new Mac running Sierra. There seems to be no solution for ImageMagick 7 at this time.
Uninstall existing imagemagick if needed
Install version 6:
brew install imagemagick#6
Since this is keg-only, you should then force-link it:
brew link --force imagemagick#6
This installed imagemagick version 6.9.7-4 for me.
Afterwards, the gem then installed successfully. I am including the version numbers for future readers:
Installing rmagick 2.13.4 with native extensions

dyson's solution didn't quite work for me. I found that in addition to installing imagemagick#6, I also need to install pkg-config and then set PKG_CONFIG_PATH.
brew install imagemagick#6 pkg-config
PATH="/usr/local/opt/imagemagick#6/bin:$PATH" PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig gem install rmagick -v '2.13.4'

Related

RMagick installation: Can't find MagickWand.h

Updating RMagick and Imagemagick is a painful expierence. I have updated the Imagemagick version on my mac (MacOS El Capitan Version 10.11.5) with homebrew for one project in Ruby 2.3 to 6.9.5-9
$ convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-09
Now an older project in Ruby 1.8.7 refuses to work with the error message "this installation of RMagick was configured with ImageMagick 6.8.9 but ImageMagick 6.9.5-9 is in use". Thus I uninstalled "rmagick", but it can not be installed again
$ gem install rmagick -v 2.16.0
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
checking for /usr/local/opt/gcc46/bin/gcc-4.6... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
And if it can not be installed, the whole application can not be started. I tried all the answers from here, and none of them works on MacOS :-( I reinstalled imagemagick and pkg-config with homebrew, and tried various version of RMagick without success. 2.16.0 is the latest version of RMagick currently.
MagicWand seems to be used in ImageMagick version > 6.9, and it can be found on the machine:
find /usr/local -name MagickWand.h
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6/wand/MagickWand.h
find /usr/local -name MagickWand.pc
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/lib/pkgconfig/MagickCore.pc
It does not work even if I specifiy the these paths during the gem install (same error as above) :-(
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
UPDATE:
The error only occurs for Ruby 1.8.7, it is possible to install RMagick for Ruby 2.0 and Ruby 2.3. Ruby 1.8.7 and ImageMagick 6.9.5 do not seem to be compatible.
Ruby 1.8.7 x
Ruby 2.0.0 ✓
Ruby 2.3.1 ✓
To solve the issue in Mac OSX Sierra, High Sierra, El Capitan, Mojave, Catalina, Big Sur, and Monterey (M1 chip), you can do the following:
brew unlink imagemagick
brew install imagemagick#6 && brew link imagemagick#6 --force
imagemagick#6 is keg-only, so you'll need to force linking.
I had this same issue with ImageMagick 7.0.4-4. The proper fix is to install imagemagick#6. I found https://github.com/Homebrew/homebrew-core/pull/8756 useful if you accidentally deleted your imagemagick#6 or never had it installed in the first place.
macOs Sierra:
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
First of all
unlink your installed imagemagick which was not properly installed in latest mac high sierra by using.
brew unlink imagemagick
then install latest imagemagic6 using below command
brew install imagemagick#6 && brew link imagemagick#6 --force
Then install gem rmagick using below command
gem install rmagick
It will work perfectly fine.
yah this one solves my issue:
MacOS X Sierra:
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
Many things have changed in ImageMagick 7 like this path: include/.../wand , and wand/MagickWand.h is hardwired in the rmagic gem at the moment. In my case it was not possible to update the gem since the project is rather old. So I ended up installing an older version of ImageMagic.
You can install the latest version from 6.x.x:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb
You can also pin it for later usege:
brew pin imagemagick
Something changed with ImageMagick 7.0.4-4 for me. wand/MagickWand.h couldn't be found any more:
% brew unlink imagemagick && brew link imagemagick
Unlinking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks removed
Linking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks created
% gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/holger/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20170116-21103-1aikaka.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
I still had ImageMagick 6.9.7-3 on my system and changed back with
% brew switch imagemagick 6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/6.9.6-6
Cleaning /usr/local/Cellar/imagemagick/6.9.7-0
Cleaning /usr/local/Cellar/imagemagick/6.9.7-1
Cleaning /usr/local/Cellar/imagemagick/6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/7.0.4-4
75 links created for /usr/local/Cellar/imagemagick/6.9.7-3
Afterwards I could install rmagick without trouble:
% gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.16.0
1 gem installed
RMagick depends on an outdated version of imagemagick, version 6.(see below) Homebrew offers this as a keg-only package, which you can install with:
brew install imagemagick#6
The build output will include a Caveats section (also available from brew info imagemagick#6 if you cleared the output):
==> Caveats
imagemagick#6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have imagemagick#6 first in your PATH run:
echo 'export PATH="/usr/local/opt/imagemagick#6/bin:$PATH"' >> ~/.zshrc
For compilers to find imagemagick#6 you may need to set:
export LDFLAGS="-L/usr/local/opt/imagemagick#6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick#6/include"
For pkg-config to find imagemagick#6 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
Rather than force-linking, which has the potential to cause problems with other software that does support newer versions of imagemagick, you can use the suggested exports to make the RMagick gem pick up the old version while it builds:
export LDFLAGS="-L/usr/local/opt/imagemagick#6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick#6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
gem install rmagick
Go help contribute to the upgrade effort if you know Ruby and C!
Install imagemagick version 6 because version 7 is not compatible:
$ brew install imagemagick#6
Should not link --force the older version because this will change the binaries in your path and the good brew doctor will complain.
Reference the headers and libraries from version 6 that was installed when building the native extension of the gem:
$ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick#6/6.9.10-14/lib/pkgconfig/ gem install rmagick -v '2.16.0'
Note: Worked for me without indicating the lib and include folder because the pkgconfig is responsible for this.
Note: 6.9.10-14 is the latest version of imagemagick#6, but feel free to change it if you need to use a different version
$ brew remove imagemagick && brew install imagemagick
$ brew uninstall pkg-config && brew install pkg-config
$ brew unlink pkg-config && brew link pkg-config
$ gem install rmagick
I don't have the reputation yet to leave this as a comment improving another answer, but #Evgeniy28's answer worked for me on Sierra only after also installing pkg-config, which doesn't come installed by default on a fresh Sierra machine.
So:
brew install pkg-config
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
Success:
$ gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.16.0
Parsing documentation for rmagick-2.16.0
Installing ri documentation for rmagick-2.16.0
Done installing documentation for rmagick after 4 seconds
1 gem installed
Please follow below and change some part according to your need.
brew unlink imagemagick
brew install imagemagick#6 && brew link imagemagick#6 --force
export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick#6/6.9.9-24/lib/pkgconfig
gem install rmagick -v '2.15.4'
With 7.0.7-1 you can create an symbolic link, but it compilation will fail latter.
cd /usr/local/Cellar/imagemagick/7.0.7-1/include/ImageMagick-7
ln -s MagickWand/ wand
ln -s MagickCore/ magick
Here is how I solved (after lots of tries and fail) on macOS High Sierra 10.13.3 with Homebrew:
it seems that RMagick 2.16.0 is not compatible with the newest version of ImageMagick (Version 7): http://wordsandmagic.com/2017/09/01/RMagick-2-16-0-Error-MagickWand
I uninstalled imagemagick: brew uninstall imagemagick
Then I installed Imagemagick with this formula: https://gist.github.com/JagdeepSingh/4b03cbeab16cc0bc729bbc6d275402d3
gem install rmagick
If you have already installed an old version Imagemagick, this should work: https://stackoverflow.com/a/41674363
There's no need to link or unlink anything, following the instructions from the brew install script helps:
brew install imagemagick#6
LDFLAGS="-L/usr/local/opt/imagemagick#6/lib" CPPFLAGS="-I/usr/local/opt/imagemagick#6/include" PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig" gem install rmagick
Am working on an legacy Ruby on Rails application (Ruby 2.1.x / Rails 3.2.x) for a client and have needed to get it running on MacOS Big Sur.
After rmagick failed wth the following output:
/Users/robbyrussell/.rbenv/versions/2.1.0/bin/ruby extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/robbyrussell/.rbenv/versions/2.1.0/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-20/2.1.0-static/rmagick-2.16.0/gem_make.out
My next step to solve this was to instruct Bundler to pass some flags to the compiler:
bundle config build.rmagick -- --with-cflags=-Wno-implicit-function-declaration
via Homebrew, I ran the following:
% brew install imagemagick#6
Then following the guidance that is output, I ran:
% export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
% bundle install
.....
Fetching rmagick 2.16.0
Installing rmagick 2.16.0 with native extensions
Voila, I'm now able to run this application locally.
Got same error for alpine 3.9 image build. It comes with ImageMagick 7.0.8.38-r0
To fix that you either use alpine 3.5 with ImageMagick 6.9.6.8-r1:
FROM alpine:3.5
Or install ImageMagick 6.9.6.8-r1 with package repository for 3.5:
RUN apk add imagemagick-dev=6.9.6.8-r1 --repository http://dl-3.alpinelinux.org/alpine/v3.5/main/
There is an open issue in rmagick repo regarding failed builds for ImageMagick 7.0.x. so hopefully it will be fixed soon.
Something was severely wrong on my system, so badly that it was completely f*d up, but I was finally to able to install RMagick for Ruby 1.8.7 again after I installed
an older version of ImageMagick with Homebrew
a new Ruby version of 1.8.7
a new version of GCC
The installation of a new Ruby version with RVM rvm install 1.8.7 also installed a new GCC compiler: it removed an older GCC version 4.6 and installed GCC version 4.9. Apparently GCC was not able to find the right headers despite pkg-config.
First, you don't need to uninstall imagemagick if it has a 6.x installed, like shown below. You can see the current "main" is 7.0.7-8 but 6.9.1-10 is still there.
$ brew info imagemagick
imagemagick: stable 7.0.7-8 (bottled), HEAD
Tools and libraries to manipulate images in many formats
https://www.imagemagick.org/
/usr/local/Cellar/imagemagick/6.9.1-10 (1,450 files, 17.5MB)
Poured from bottle on 2015-07-26 at 09:10:58
/usr/local/Cellar/imagemagick/7.0.6-9 (1,522 files, 22.8MB)
Poured from bottle on 2017-08-21 at 14:44:16
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula
If you don't have an old 6.x version, then install imagemagick#6.
Second, do not force link imagemagick, especially not 6. EDIT: See ¹
You need to set PKG_CONFIG_PATH in addition to the --with-opt-* flags.
This works for me on High Sierra with aforementioned brew setup on Ruby 1.9.3-p551:
PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.1-10/lib/pkgconfig \
gem install rmagick -v '2.16.0' -- \
--with-opt-lib=/usr/local/Cellar/imagemagick/6.9.1-10/lib/ \
--with-opt-include=/usr/local/Cellar/imagemagick/6.9.1-10/include/ImageMagick-6/
Building ri docs fails, but those are inconsequential.
¹: Building works, the dylib path RMagick is searching is wrong though. Raised Issue #278 to clarify if this can be fixed. Otherwise manual symlinking of libMagickWand etc is necessary. Might still be safer to manually link the specific libraries than a brew link --force though.
I fully explain the installation process in ImageMagick install in centos .
anyway ...
after install Install Imagick & ImageMagick-devel & ImageMagick PHP library like below:
# yum install ImageMagick
# yum install ImageMagick-devel
# pecl install Imagick
go to /usr/include
cd /usr/include
Important: copy ImageMagick folder from "/usr/include" to "/usr/local/include" for ImageMagick find "MagickWand.h"
I tested this change on imagick-3.4.3(ImageMagick-7) and centos 6.5 and php56 and works perfectly ...
If you have already installed "ImageMagick" several times, first remove all of them and find "ImageMagick" & "imagick" folders and clean all of them and continue the installation process with this change.
Use the following command to find a file or folder:
find / -name 'ImageMagick*'
find / -name 'imagick*'
and continue your installation
before below lines don't forget:
go to "php.ini" find "disable_functions" and clean "proc_open,popen,proc_close" becuase make imagick needs these functions,
after complete installation you can add this functions to your "disable_functions" on "php.ini" file.
# phpize
# ./configure --with-php-config=/usr/local/php56/bin/php-config
...
Good luck...
For Ubuntu version > 12 and not using homebrew,
wget http://www.imagemagick.org/download/<required_imagemagick_version>
tar -xvf <path_to_your_downloaded_file>.tar.gz
If you are getting '7z' files instead of 'tar.gz' files in the wget link, then
7z x <path_to_your_downloaded_file>.7z
cd <path_to_your_downloaded_file>/
make
./configure
sudo make install
sudo ldconfig /usr/local/lib
Then you can resume your bundler for RMagick.

RVM requirements error

I have OS X Mavericks installed and I'm trying to run rvm requirements in terminal and it gives me this error.
Installing required packages: autoconf, automake, libtool, pkgconfig, libyaml, libffi, readline, libksba, curl-ca-bundle, gdbm.............
Error running 'requirements_osx_port_libs_install autoconf automake libtool pkgconfig libyaml libffi readline libksba curl-ca-bundle gdbm',
please read /Users/Alex/.rvm/log/ruby-1.9.3-p448/1374263757_package_install_autoconf_automake_libtool_pkgconfig_libyaml_libffi_readline_libksba_curl-ca-bundle_gdbm.log
Requirements installation failed with status: 1.
It looks like RVM tried to install some dependencies using Macports and Macports proceeded to get really confused about dependencies when it tried to install autoconf.
Try running:
brew install autoconf
Otherwise you should run this bash script:
https://gist.github.com/siraj/1399288
Assuming you have brew, which you should if you don't.
If your Macports just isn't working, then you can manually install all of the requirements like this:
brew install autoconf automake libtool pkgconfig libyaml libffi readline libksba curl-ca-bundle gdbm
I tried the above, and a few other things. None worked.
It seems that on OSX 10.9 and XCode5 moved some libs around on us. So I had to install XCode5-DP6 (Dev Preview 6), opened up DP6 and in the settings, you have to tell the command line tools to use the new DP6 build and not the Standard XCode from the marketplace.
First, I had to install homebrew. Nothing liked to play with macports. I am on my first mac as of only a month ago, so macports was just what solved apache for me at the time. I then had to run 'brew install autoconf'
Once I did that I then ran rvm requirements, everything installed without issue. then sudo gem install jekyll from there and it all works like a charm now.
I'm sure once Mavericks is actually released this will get ironed out. We are using early releases after all...
Hope this works for you guys.

Can't install RMagick 2.13.1. Can't find MagickWand.h.

When I try do install rmagick I get the following error message:
Can't install RMagick 2.13.1. Can't find MagickWand.h.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
I'm on Mac OSX 10.6.8, ruby 1.9.2p290, rvm 1.10.2.
Can anyone help me please to solve this problem.
If you're on Ubuntu, installing this package is what fixed it for me:
sudo apt-get install libmagickwand-dev
It looks like ImageMagick 7 changed include file path.
On building rmagick, since it includes file as wand/MagickWand.h There are no workarounds. It looks like sticking with ImageMagick 6 for now.
On Mac OS X (I tested on Sierra), I used HomeBrew's versions tap like:
brew tap homebrew/versions
brew install imagemagick#6
Then, use the path shown on above installation:
PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig gem install rmagick
To install with ImageMagick 6.
I didn't want to mess with environment variables since I wanted bundler to be able to compile this gem on its own on a CI machine. Instead, I used Homebrew to install pkg-config:
brew install pkgconfig
and the next time I tried compiling the RMagick gem it found the header file without issue.
(This is pkg-config 0.28, ImageMagick 6.8.0-10, and RMagick 2.13.2, all on Mountain Lion.)
I had a similar issue with running
$ gem install rmagick
First of all, do you have imagemagick installed? If you're not sure, run
$ convert --version
If you do, you probably either installed it with fink or macports (maybe homebrew?). What is happening is that rvm can't find the imagemagick directory.
After reading
https://superuser.com/questions/361435/i-have-compiled-imagemagick-on-my-centos-and-rmagick-wont-install
I exported the imagemagick path by adding
$ export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
to my ~/.bash_profile, sourcing the new profile, then running:
gem install rmagick
It worked for me after I did this.
fix this setting the include path of your current imagemagick installation:
Install ImageMagick with brew
brew install imagemagick
find library
$ mdfind MagickWand.h
/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/wand/MagickWand.h
Install rmagick gem
$ C_INCLUDE_PATH=/path/MagickWand.h gem install rmagick
example:
$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/ gem install rmagick
I marked this as a favorite because it seems to come back to bite me with every new system I need to install RMagick on (and time has passed and version numbers have rolled).
Mac OS X 10.8.4
rvm 1.22.3
ruby-2.0.0-p247
Xcode 4.6.3 developer tools installed
$ brew install imagemagick
==> /usr/local/Cellar/imagemagick/6.8.6-3
$ brew install pkgconfig
==> /usr/local/Cellar/pkg-config/0.28
$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/lib/pkgconfig/ gem install rmagick
Successfully installed rmagick-2.13.2
Many thanks to everyone who added helpful answers above!
Mac users using brew
If you can use v6 of ImageMagick instead of 7, you can try this
brew install imagemagick#6 --force && brew link imagemagick#6 --force
Note this will unlink your existing IM installation, so be careful if you have other projects on your machine using ImageMagick without problems.
For my own and others edification, I got past the error about the magicwand.h by using the suggestion xonico. MDFind plus the C_INCLUDE_PATH. However, it then gave me an error about MagickCore.pc. My final command to get this working had to include both like so:
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/ gem install rmagick
Obviously your paths will vary depending on whether you're using brew like me and what version of imagemagick you were installing. Also, xcode command line tools did have to be installed, as others have mentioned.
Thanks for everyone's posts on this! I am plussing your answers since it contributed to mine!
For Ubuntu:
sudo apt-get install imagemagick libmagickwand-dev
gem install rmagick
I had a problem after update to Maverics.
It have lost a lot of linkings.
In my case I had to refresh links to pkg-config
brew unlink pkg-config
brew link pkg-config
Then installing rmagick worked like a charm.
I updated to Mountain Lion and started getting this same problem. I had to re-install brew, XCode, the XCode tools - pretty much the whole environment!
I eventually solved this problem using the answer from phopkins above...
brew install pkgconfig
Once that was successfully completed (I had to delete some old symlinks first) then I was able to successfully install the RMagick gem
This worked for me on Mac OsX
Install Imagemagick:
brew remove imagemagick
brew install imagemagick
Make sure pkg-config is correctly linked:
brew uninstall pkg-config
brew install pkg-config
brew unlink pkg-config && brew link pkg-config
Install gem
gem install rmagick
For Ubuntu users:
It will never done directly on Ubuntu. You should first install packages to run this command...:
sudo apt-get install libmagickwand-dev
...and then do install:
gem install rmagick
You may get the same issue, for that, Try clearing your apt repository and removing any broken packages first:
sudo apt-get update
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove
If the system identifies any broken packages, forcefully remove them (replace package_name with your own):
sudo dpkg --remove -force --force-remove-reinstreq package_name
Then re-install any missing packages again. :)
An issue for me was that rmagick is out of date and not updated regularly. If you have too new of an ImageMagick version, then it might not be compatible. Check your version of ImageMagick using the following:
$ convert --version
If the ImageMagick version is > 7, it is not compatable with rmagick. The user will get errors such as
Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** extconf.rb failed ***
Go back to version six of ImageMagick until they update rmagick to be compatible with version seven of ImageMagick. Someone has hosted the appropriate version(6) in a separate gem - 'imagemagick#6'.
If you need rmagick to work but currently have an imagemagick version 7 or higher, here are the steps to switch:
$ gem install imagemagick#6
$ brew unlink imagemagick
$ brew link imagemagick#6 --force
Helped me on Debian Wheezy 64bit
apt-get install libmagickcore-dev libmagickwand-dev
Try reinstalling both Imagemagick and PkgConfig. That should fix it for Mavericks
brew update && brew upgrade
brew reinstall imagemagick
brew reinstall pkgconfig
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick gem install rmagick
I was really struggling with this on OS X Mountain Lion (after upgrading from Lion) and none of the suggestions regarding C_INCLUDE_PATH, PKG_CONFIG_PATH, ln'ing various files, etc., were working. On the same day I upgraded to Mountain Lion, I also upgraded XCode to 4.5.2, but I didn't really think too much of this.
Eventually I stopped trying to install RMagick and had to pass on the work to a colleague.
Then, by chance, I found that I was trying to use bundle install on another project and I wasn't able to install the json gem because "make" could not be found. I checked into that and found you need to go to XCode -> Preferences -> Downloads and install the command line tools to get make working again. The json gem installed fine.
Then I paused...and tried
gem install rmagick
One more time. It worked perfectly.
for a rails based application, I found this
sudo apt-get install -y libmagickwand-6-headers
C_INCLUDE_PATH=/usr/include/ImageMagick-6 gem install rmagick
bundle update rmagick
bundle install
worked on debian jessie
I ran into this because I'd run OS X's Migration Assistant and nothing was relinked after the migration. You need to check the output of Wand-config --ldflags --libs. In my case it gave:
$ Wand-config --ldflags --libs
/usr/local/bin/Wand-config: line 50: pkg-config: command not found
/usr/local/bin/Wand-config: line 53: pkg-config: command not found
After relinking pkg-config, libpng, and libfreetype, that became:
$ Wand-config --ldflags --libs
-L/usr/local/Cellar/imagemagick/6.8.8-9/lib -lMagickWand-6.Q16 -lMagickCore-6.Q16
-L/usr/local/Cellar/imagemagick/6.8.8-9/lib -lMagickWand-6.Q16 -lMagickCore-6.Q16
And then:
$ gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.13.2
Parsing documentation for rmagick-2.13.2
Done installing documentation for rmagick after 4 seconds
1 gem installed
In linux OS:
C_INCLUDE_PATH=/usr/local/include/ImageMagick-6/ gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/home/vagrant/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
...
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
then:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
in my .bashrc file to pick up MagickCore.pc, then created two symlinks:
ln -s /usr/local/include/ImageMagick/wand /usr/local/include/ImageMagick-6/wand
ln -s /usr/local/include/ImageMagick/magick /usr/local/include/ImageMagick-6/magick
Now:
$ gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.13.2
1 gem installed
boom everything works fine.
At arch linux, after installing imagemagick#6, gem wasn't able to install package rmagick and got error below.
Can't install RMagick 2.16.0. Can't find MagickWand.h
Worked for me using below steps
added pkgconfig path to .bashrc
export PKG_CONFIG_PATH="/usr/lib/imagemagick6/pkgconfig"
Created two symlinks as below
ln -s /usr/include/ImageMagick-6/wand /usr/include/ImageMagick-6/wand
ln -s /usr/local/include/ImageMagick/magick /usr/include/ImageMagick-6/magick
There are some variants to this problem. Mostly the case is dealing with a legacy application that run older versions of ruby.
rmagick has a dependancy on imagemagick... but not just any. If you've gone too far ahead, it may be wise to backtrack:
brew uninstall imagemagick
Then proceed with an appropriate version
brew install imagemagick#6
then you path needs to be adjusted and forced upon homebrew
export PATH="/usr/local/opt/imagemagick#6/bin:$PATH"
brew link --force imagemagick#6
then you can install rmagick to most recent or versioned
gem install rmagick -v '2.15.4' --source 'https://rubygems.org/'
I had a hard time getting this same issue to work when I had a default ImageMagick install on OSX 10.8 (no homebrew or macports). No combination of the suggestions in this thread or threads linked to from this thread worked for me (modifying the paths for my local install of course).
I simply deleted the default ImageMagick 6 install, and then reinstalled with macports. My rmagick install worked immediately after with no other changes.
on OSX Maverick 10.9.1
it took me ages to figure it out but I solved these issues the following way:
nano /etc/paths
changed:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
into:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
that that local stuff, like 'brew' is loaded first.
now I hit 'brew doctor' into the terminal, to see if there's something messed up
if you get the following output
Your system is ready to brew.
everthing is fine. if not ti will tell you what to do. Like kick out unbrewed stuff, broken libs, clean symlinks and whatnot.
When you are ready to brew, you need ghostscript(for pdfs), libpng, imagemagick via brew.
then you can happily type : 'gem install rmagick', in case you did't kill your ruby setup. But thats easy to reinstall via your cleaned up brew.
PS:
another helpful command is: 'which convert', to show you what version of imagemagick is used by the system.
as well as --version
so if you installed git via brew and do 'git --version' and it returns some apple git version, your load path is broken...
On Mac OS X 10.9, try to update your Xcode if there's a warning about it.
$ brew doctor
I you found some warning, do:
$ sudo /Developer/Library/uninstall-developer-folder
Then try:
$ bundle install
again
That worked fine for me.
On CentOS 6.5 x64, it was pretty easy:
yum install ImageMagick ImageMagick-devel
gem install rmagick -v '2.13.2'
I was able to fix this by upgrading to 2.13.2
All brew options failed to install rmagick 2.13.1 on yosemite 10.10
this worked
get the latest RVM
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install 2.1.1
rvm use 2.1.1
download and install the package file
http://cactuslab.com/imagemagick
(I used pacifist to install)
Confirm location of MagickCore.pc file
mdfind magickcore.pc
eg. /opt/ImageMagick/lib/pkgconfig/MagickCore.pc
Manually download rmagick-2.15.2.gem file
https://rubygems.org/gems/rmagick/versions/2.15.2
from that dir
sudo C_INCLUDE_PATH=/opt/ImageMagick/include/ImageMagick-6/ PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig gem install --local rmagick-2.15.2.gem
If you are having issues with bundle installer still complaining about 2.13.1
In your gem file / gem.lock file upgrade ALL dependencies
rmagick (2.13.1) - > rmagick (>= 2.15.2)
Got same error for alpine 3.9 image build. It comes with ImageMagick 7.0.8.38-r0
To fix that you either use alpine 3.5 with ImageMagick 6.9.6.8-r1:
FROM alpine:3.5
Or install ImageMagick 6.9.6.8-r1 with package repository for 3.5:
RUN apk add imagemagick-dev=6.9.6.8-r1 --repository http://dl-3.alpinelinux.org/alpine/v3.5/main/
There is an open issue in rmagick repo regarding failed builds for ImageMagick 7.0.x. so hopefully it will be fixed soon.

ImageMagick and OS X Lion trouble

[edit] I was troubleshooting problems with my development environment when I noticed one of my problems was the dependency on ImageMagick, since it's a vital part of my app.
After upgrading to OS X Lion (10.7) i no longer had ImageMagick available, i then tried installing again using MacPorts without success, i then installed from source, and the install wasn't very successfully i had convert and identify but it output error messages that i unfortunately dont have anymore, i by some strange reason decided to remove all of my MacPort libraries and started using Homebrew, i tried installing ImageMagick, it installs OK but when i try to use it throws this error
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 11.0.0 or later, but libltdl.7.dylib provides version 10.0.0
Trace/BPT trap: 5
I read online but i have no clue on whats going on here, i found that libltdl is called libtool, and that i obviously need to upgrade it to a newer version, but i havent found any indication of how or where to find the source, or if this should be already be handled by homebrew and why it hasn't.
I tried installing ImageMagick again from source using this installer script https://github.com/masterkain/ImageMagick-sl but when i try to use convert it throws a similar error.
$ convert gnome.jpg -resize 50% gnome_.jpg
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 11.0.0 or later, but libltdl.7.dylib provides version 10.0.0
Trace/BPT trap: 5
$ which convert
/usr/local/bin/convert
What can i do to solve my problem?
On 10.8 I solved this issue with:
brew install libtool --universal
brew link libtool
If you don't know what brew is, visit https://github.com/mxcl/homebrew and its wiki.
brew uninstall imagemagick
brew install imagemagick --build-from-source
worked for me
I too use homebrew for installing packages but imagemagick stopped working after upgrading OSX 10.8 to 10.9 (Mavericks). I had to do the following steps:
brew uninstall imagemagick
brew uninstall libtool
brew install libtool --universal
brew install imagemagick --build-from-source
Why the --build-from-source? Well for me running brew install imagemagick on its own to install the pre-built binary wasn't sufficient; it fixed the original 'dyln' error but was replaced with:
unable to load module `/usr/local/Cellar/imagemagick/6.8.7-7/lib/ImageMagick//modules-Q16/coders/png.la': file not found # error/module.c/OpenModule/1277
I also upgraded to Lion and lost ImageMagick, although i'm getting different errors.
i found a Lion distribution on imagemagick.org. not a big fan of the DYLD_LIBRARY_PATH environment variable but it works.
ok scratch that. i just downloaded the ImageMagick source and re-compiled:
cd /tmp
curl -OL ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-6.7.2-7/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
On Mountain Lion OSX,
Even with the updated brew for imagemagick(which includes libtool), this error seemed to happen to me.
so i fixed it using the following commands
brew uninstall libtool
brew install libtool --universal
brew link libtool --force
For others looking and still having trouble, I used this:
https://github.com/maddox/magick-installer
On 10.8, with brew, I solved this issue with:
brew install graphicsmagick
For the googlers: If you happened to have it installed with brew beforehand, you'll need to reinstall by running brew uninstall graphicsmagick before installing again. Easy.
This helped me after restoring OS X 10.9.3 from time machine.
brew uninstall imagemagick
brew uninstall libtool
brew install libtool --universal
brew unlink libtool && brew link libtool
brew install imagemagick
brew install Homebrew/python/pillow
brew link --overwrite pillow
The same problem might occur with OSX Mountain Lion (preview 4). I had to configure some parts separately because there are some library incompatibilities:
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 13.0.0 or later, but libjpeg.8.dylib provides version 9.0.0
I had to add --with-fontconfig=no, --with-lzma=no and use /opt/local/share/... instead of /usr/local/share/... for the ghostscript fonts:
cd /tmp
curl -OL ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-6.7.8-0/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp --with-fontconfig=no --with-gs-font-dir=/opt/local/share/ghostscript/fonts --with-lzma=no
make
sudo make install
I could fix the ImageMagick problem by installing corresponding package from cactuslab site.
Then by setting the PATH variables in terminal:
export MAGICK_HOME="/usr/local/ImageMagick/"
export PATH="$MAGICK_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
If you're using Homebrew, try the following command:
brew doctor
to diagnose the common problems.
One of it could be to remove DYLD_FALLBACK_LIBRARY_PATH variable from your ~/.profile if you have it.
Or you have to re-install libtool by:
brew reinstall libtool --universal && brew unlink libtool && brew link libtool
I tried most of the solutions above and they didn't work. Here's how I fixed my problem:
brew install imagemagick;
brew install freetype;
cd /usr/X11/lib/;
sudo mv libfreetype.6.dylib libfreetype.6.dylib.orig;
sudo ln -s /usr/local/opt/freetype/lib/libfreetype.6.dylib libfreetype.6.dylib
Tested on OS X 10.7.2
For 10.7.8 and up, you have to install the php version and not the pecl version. Depending on your version of php you've install with Macports you can either do:
sudo port install php-imagick
sudo port install php5-imagick
sudo port install php53-imagick
sudo port install php54-imagick
Remember only to do the one of your current version of php.

RMagick RVM installation failed

I keep getting this error when I'm installing rmagick inside rvm.
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.13.1. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
Here's my current setup:
Snow Leopard 10.6.7
XCode 3.2.6
RVM 1.6.1
Ruby Over RVM (ree1.8.7)
Homebrew 0.8
ImageMagick 6.6.9-4 c/o Homebrew
After installing imagemagick with Homebrew, I was able to install rmagick using the system ruby
rvm system
sudo gem install rmagick
Any ideas?
I think that there was a problem with the imagemagick package from homebrew for a small period of time. I just walked through re-installing rmagick on my system (also 10.6.7 with RVM). First I re-installed imagick:
brew uninstall imagick
and then
brew install imagick
Finally I did
gem install rmagick
Which compiled with no problems. I can't see why it would cause you problems but you don't need to use sudo when use rvm unless you installed RVM as root.
RMagick expects for Homebrew to provide certain symlinks which don't exit, causing a whole lotta problems.
You can run this gist to create the symlinks specific to your ImageMagick installation that are needed for RMagick to work.

Resources