Ruby gem rmagick won't install on Mac OS X - ruby

I understand that this question has been asked a lot earlier, but none of the solutions worked for me and I'm really desperate right now.
I'm trying to get rMagick to install using gem for an installation of diaspora. I already installed imagick via homebrew and when trying to run gem install rmagick I receive this error:
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/bin:/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#global/bin:/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin:/Users/tobischweiger/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
*** 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/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby
Gem files will remain installed in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
I'm not very experienced with gem and homebrew and I'm wondering if somebody could help me out.

Run this (using homebrew) before attempting to install the gem.
brew install imagemagick

This is the less destructive version using homebrew, rmagic also doesn't work with imagemacigk version 7
ImageMagick Version 6.4.9 or later (6.×.x). Version 7 is NOT yet
supported; ETA April 2019 (https://github.com/rmagick/rmagick/pull/299 )
(from Readme)
. You can get ImageMagick from www.imagemagick.org., so with brew try this
brew install imagemagick#6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig gem install rmagick

I'm using OS X Lion.
I ran brew doctor and saw that imagemagick was unlinked so it told me to run brew link imagemagick.
Then I closed and re-opened my terminal and everything worked thankfully.

On Mavericks, you can do it:
brew install pkgconfig
brew uninstall imagemagick
brew install imagemagick
brew link imagemagick
bundle install
It's enough. I think.

I had a similar issue and this worked for me:
$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib
Hope this helps.
Credit: https://coderwall.com/p/wnomjg

Make sure when you do these:
$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib
that you change the file names to reflect your version: you can see the filenames by looking in the lib folder here: cd /usr/local/Cellar/imagemagick/VERSION/lib
ex:
ln -s libMagickWand-6.Q16.1.dylib libMagickWand.dylib
and so on

There are different scenarios we need to check while installing RMagick. Please check following and confirm:
Check if you are not installing latest version of RMagick with older version of ruby. i.e. ruby 1.8.7 or so. You can not install latest version of RMagick with older version of Ruby. If so, you will probably get this error message.
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/user/.rbenv/versions/1.8.7-p375/bin/ruby extconf.rb
Make sure you have installed imagemagick before you install RMagick.
brew install imagemagick
Also make sure you are installing RMagick with compatible version of imagemagick. RMagick is not compatible with latest version of imagemagick.
More to this:
instead of using RMagick you can use MiniMagick if you just need to resize, sharpen, transform existing images. RMagick is required when we need to create image, graphs, drawings and typography. It’s easier to work with and much lighter on system resources than RMagick. RMagick consumes huge amount of memory.

The main issue seems to be getting imagemagick properly installed and linked.
This page was very helpful for me:
http://sethvargo.com/20110726/install-imagemagick-on-mountain-lion/
I'm running homebrew, and getting the brew doctor command to run clean was the key to getting this to install.

I found that updating my Xcode to the latest version (4.6.1) on OSX 1.8.2 fixed this problem and I Successfully installed rmagick-2.13.2

For me, I had to look at the output which in your case is
/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2/ext/RMagick
In there is a file called mkmf.log that lists exactly what it is trying to compile and the error. For me, the linker was failing with this command:
ld: library not found for -lMagickCore
Reviewing the command it was running it looked good except for the very end, see this snippet:
-lMagickCore-6.Q16 -lMagickCore-6.Q16 -lruby-static -framework CoreFoundation -lMagickCore -lpthread -ldl -lobjc -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Note that it got the output from Magick-config and used those by adding -lMagickCore-6.Q16 but it was still trying to link -lMagickCore. I think this is a byproduct of the have_library extconf is using. Important for me, was that there was no libMagickCore.dylib library provided by Homebrew. It could be an old version of rubygems and I think the correct fix would be to update the have_library function but I fixed it by making a symlink called libMagickCore.dylib that pointed to libMagickCore-6.Q16.dylib.

Related

Mac OS 10.14 Mojave + qt5.5 + gem capybara-webkit

My config is MAC Mojave v10.14.
I try to install gem Capybara-webkit -v '1.15.0' which need qt5.5, but qt5.5 has been dropped of the homebrew and it is not compatible with Xcode v10.
I try this :
Uninstall Xcode v10
Install Xcode 9.4.1, found in developer.apple.com/
Install qt5.5, I have found it in the archives on qt.io/
Run bundle
But it fail, my error is with the gem capybara-webkit -v '1.15.0':
Fetching capybara-webkit 1.15.0
Installing capybara-webkit 1.15.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara-
webkit-1.15.0
/Users/thomas/.rbenv/versions/2.4.4/bin/ruby -r ./siteconf20181005-763-1bppnfh.rb extconf.rb
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
*** 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/thomas/.rbenv/versions/2.4.4/bin/$(RUBY_BASE_NAME)
--with-gl-dir
--without-gl-dir
--with-gl-include
--without-gl-include=${gl-dir}/include
--with-gl-lib
--without-gl-lib=${gl-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
Command 'qmake ' failed
extconf failed, exit code 1
Gem files will remain installed in
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara-webkit-1.15.0 for inspection.
Results logged to /Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/extensions/x86_64- darwin-18/2.4.0-static/capybara-webkit-1.15.0/gem_make.out
An error occurred while installing capybara-webkit (1.15.0), and Bundler
cannot continue.
Make sure that `gem install capybara-webkit -v '1.15.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
capybara-webkit
Next, I did:
sudo xcodebuild -license agree
But the error persists...
Thank you for your help !
As described on the capybara-webkit wiki, capybara-webkit depends on Qt 5.5. "Qt 5.5 is the last version of Qt that capybara-webkit will support. The Qt project has dropped the WebKit bindings from binary releases in 5.6."
To install Qt 5.5 follow the instructions from the wiki. For Mojave, the instructions are the following.
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt#5.5.rb
brew install qt#5.5
echo 'export PATH="$(brew --prefix qt#5.5)/bin:$PATH"' >> ~/.bashrc
You can confirm this step worked by running:
$ which qmake
/usr/local/opt/qt#5.5/bin/qmake
Next, you need to install Xcode 9.4. Xcode 10 is not compatible with Qt 5.5. Xcode 9.4 can be downloaded from the Apple developer portal. This is a 4GB download and takes about 30 minutes to download and install. You can verify it's correctly installed by running the following:
$ /usr/bin/xcodebuild -version
Xcode 9.4.1
Build version 9F2000
If this doesn't work, it may be because you have only the Command Line Tools installed instead of Xcode, in which case you should make sure you downloaded the right version of Xcode. Or the Xcode folder may set incorrectly. If so, you can fix this using xcode-select, which will specifiy the folder in which xcodebuild runs:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
When Xcode is finally installed, locate it in your Applications folder, open it, and agree to the license. Then try reinstalling capybara-webkit.
Disclaimer: I came up with the above answer from compiling multiple questions and answers and trying to remember the order in which I ran commands on my local machine. I may have accidentally omitted some steps.
Here's what worked for me, found here:
Keep your xcode v10 installed
Manually download and install Qt 5.5 from their website
Add Qt's bin path to your PATH environment variable by adding this to your .bashrc, .zshrc or any other shell configuration that you have: (make sure to replace /Applications/Qt/5.5/clang_64/bin with your Qt bin path)
export PATH="/Applications/Qt/5.5/clang_64/bin:$PATH" # Add Qt bin to path for capybara webkit to work
Run gem install capybara-webkit
I think my problem was with xcrun. For fix I did :
sudo chown root:wheel /Applications/Xcode.app
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun
And it work (y) !
You need Xcode 9.4.1 to install qt#5.5 as it's not compatible with Xcode 10. Homebrew has deleted the qt#5.5 from their core tap so to install it you need to run the following before:
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt#5.5.rb
brew install qt#5.5
9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 is the parent commit of 360923286c0f1a6a1325ada578df030bf579009f where they removed qt#5.5 so this command rollbacks to the parent commit and checkout the needed formula file.
I could install qt#5.5 on Mojave with this:
brew install qt#5.5 --force-bottle
With capybara-webkit, I temporarily use this:
gem "capybara-webkit", git: "https://github.com/emilyst/capybara-webkit.git", ref: "9c9af833656f095667e8522004dae017d423d37d"

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.

How to install ruby-debug when needing necessary libraries and/or headers

My Rails is 3.2.1.4, Ruby is 1.9.3p448.
I got an error when I install ruby-debug:
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.
/home/hxh/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
Can't handle 1.9.x yet
*** 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=/home/hxh/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
Gem files will remain installed in /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46 for inspection.
Results logged to /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46/ext/gem_make.out
Who can tell me where the error is?
The error is in the mkmf.log file. That file should be located at /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46/ext/linecache/mkmf.log.
If not, you can use
sudo find / -name mkmf.log
to find it.
To troubleshoot further, see "How to install Nokogiri Ruby gem with mkmf.log saying libiconv not found?"
I am using Mac El Capitan. In my case it was caused by the missing developer tool. I solved it by installing the developer tool via xcode-select --install. After that bundle install worked fine again.
You're most likely missing some file headers (e.g. zlib or libiconv), so try installing them.
Linux: sudo apt-get install libz-dev libiconv-hook1 libiconv-hook-dev
OS X: brew install libiconv && xcode-select --install
Otherwise check your mkmf.log file for more specific details.
I was facing the same issue running MacOS Big Sur version 11.1 and Xcode Version 12.4 (12D4e). In my case there was no command-line tool selected in Xcode.
I just followed the following steps to fix the problem:
Start Xcode.
Open the preferences using ⌘+,.
Select the Locations tab.
Select command-line tool (Xcode 12.4 12D4E in my case).
Run sudo gem install cocoapods (in my case).
It seems to be a issue with permission of gcc.. however, if you're using OS X, you may encounter this issue if you've updated your XCode but haven't agree to their terms & conditions yet.. try typing gcc in your terminal would show you what if you've agreed.
My mkmf.log showed that gcc (4.8.2 I think) didn't like a specific argument that was being used by atomic on
$ gem install atomic
So I had a very similar situation. The answer for me was to upgrade gcc/gcc-libs and lib tool.
I use Arch linux, and only Arch linux. The proper way to do this is to run
$ sudo pacman -Syu
which upgrades all system packages.
I installed Rails and hadn't run a system update since, which is where the issue came from. In most other *nix distros, you would update to the latest version of these packages by name, i.e. with apt, it would be something along the lines of
$ sudo apt-get update
followed by
$ sudo apt-get upgrade {package-name}
For what it's worth, using Ruby 2.0.0 I was having this problem on OSX 10.10.
I ended up running brew update, which resolved some conflicts, then installed the gem and it was fine.
The answer of kenorb worked for me on Ubuntu 16.04 when I was trying installing rails! Thanks!
I followed these steps below for installing rails:
sudo apt-get install ruby-full
sudo apt-get install libz-dev libiconv-hook1 libiconv-hook-dev
sudo gem install rails
I had the issue because gcc wasn't available on my machine.
Fixed it by installing gcc.
sudo apt install build-essential
This worked for me. Nokogiri was the problem.
Try the following if you are using Alpine-Linux(or equivalent command for your OS):
apk add build-base
And then install Nokogiri using:
gem install nokogiri -- --without-pkg-config --with-libxml-2.0-config
Took me a while to successfully install it.
Install cocoapods with HomeBrew brew install cocoapods && brew link --overwrite cocoapods
Verify your cocoapods version pod --version
This is probably happening because your computer has an older version of Ruby, so first update Ruby. This worked for Ruby 2.6.3+.
Open terminal and enter:
curl -L https://get.rvm.io | bash -s stable
Then:
rvm install ruby-2.6
This will install Ruby for you if it wasn't already installed, then update Ruby to the new version:
rvm use ruby-2.6.3
This will possibly fix your issue. You can now enter:
sudo gem install cocoapods
pod setup
If RVM is not installed in your system, then use:
$HOME/.rvm/scripts/rvm
rvm
The problem is resolved with next command: sudo apt install build-essential
This worked for me:
sudo apt-get install libmysqlclient-dev
Install RVM and use it to install Ruby 2.6.x:
curl -sSL https://get.rvm.io | bash
rvm install 2.6.x
rvm use ruby-2.6.x
Now try and it should work:
sudo gem install cocoapods

Installing RMagick gem -- Can't find MagickWand.h

I am installing the rmagick gem on OSX 10.6.8, using gem install rmagick, and I am getting the following error
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.
Provided configuration options:
--with-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/disaacs/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
Gem files will remain installed in /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
Looking in the mkmf.log file I see
have_header: checking for wand/MagickWand.h... -------------------- no
"/usr/bin/gcc-4.2 -E -I/Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/backward -I/Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. conftest.c -o conftest.i"
conftest.c:3:29: error: wand/MagickWand.h: No such file or directory
It's true. The file MagickWand.h is not found in any of the directories specific by the -I directives of the gcc-4.2 command. Why not? And how can I fix this?
ImageMagick is installed, using homebrew. If I search my drive I find MagicWand.h installed in /usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/wand/MagickWand.h.
I've tried all the suggestions in Can't install RMagick 2.13.1. Can't find MagickWand.h., but none of them have worked.
Edit:
Another thing to note: I originally had ImagMagick 6.7.0-7 installed using MacPorts, and RMagick installed just fine. Except that it would not work with the CarrierWave gem. So I uninstalled MacPorts and uninstalled RMagick. Then reinstalled ImageMagick using brew install -f imagemagick --disable-openmp, and attempted to reinstall the rmagick gem (which brings me to my current problem). I restarted all terminals at each step, to ensure that my paths were refreshed.
For Debian-based (e.g., Ubuntu) systems you can try,
sudo apt-get install libmagickcore-dev libmagickwand-dev
gem install rmagick
it works for me.
found solution from ruby-forum
1) install by installer
http://cactuslab.com/imagemagick/
2) try gem install rmagick
if checking for wand/MagickWand.h... no
type
mdfind MagickWand.h
find some thing like
/Users/user/ImageMagick-6.8.3/include/ImageMagick-6/wand/MagickWand.h
and type in terminal
C_INCLUDE_PATH=/Users/user/ImageMagick-6.8.3/include/ImageMagick-6/ gem install rmagick
if, after that you have this error (because a had it) "Package MagickCore was not found in the pkg-config search path."
type
mdfind MagickCore.pc
find some thing like /opt/ImageMagick/lib/pkgconfig/MagickCore.pc
and finally in terminal type:
PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ gem install rmagick
Turns out the answer was in Can't install RMagick 2.13.1. Can't find MagickWand.h. after all. I had just followed the suggestion incorrectly.
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick gem install rmagick
This installed rmagick gem successfully.
Unfortunately, rmagic is still not working with CarrierWave :-(, but that is a different problem altogether.
Here's a solution for OS X Mavericks - at least it worked for me...
First, install Xcode 5 (from the App Store)
Then install development-tools - open Terminal and type:
xcode-select install
Next, grab the ImageMagick package from CatusLab: http://cactuslab.com/imagemagick/
(I opted for the package without Freetype support, that requires XQuarz - but it's really up to you).
You'll need pgkconfg as well - get it here: http://macpkg.sourceforge.net
Once installed, export the pkgconfig binary:
export PATH=/opt/pkgconfig/bin:$PATH
Then find the MagickWand.h
mdfind MagickWand.h
it puts out the path to MagickWand.h, in my case /opt/ImageMagick/include/ImageMagick-6/wand/MagickWand.h
Next find the pkgconfig path:
mdfind MagickCore.pc
For me it put out: /opt/ImageMagick/lib/pkgconfig/MagickCore.pc
I had the problem that rmagick gem couldn't be fetched so I downloaded it from rubygems.org/gems/rmagick
With the rmagick gem downloaded to your Download folder you should now be able to install rmagick:
sudo C_INCLUDE_PATH=/opt/ImageMagick/include/ImageMagick-6/ PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ gem install --local ~/Downloads/rmagick-2.13.2
For me it installed successfully - hope this helps...
I wasted a lot of time on this, ImageMagick versions above 6.7 don't play nicely with the installation of the rmagick gem. It looks like someone made a package to address this issue, try:
brew install imagemagick-ruby186
After uninstalling your previous imagemagick. Afterwards gem install rmagick worked fine for me.
I am on OS X El Capitan.
My app is using ruby 2.1.2 and rmagick 2.13.4.
When using brew install imagemagick I get ImageMagick -v 7.0.4-5.
The solution for me was to use brew install imagemagick#6 which gave me ImageMagick -v 6.9.7-5 which allowed me to successfully install the gem.
here's what i did on 16.04.1,
sudo apt-get install libmagickwand-dev
sudo apt-get install graphicsmagick-imagemagick-compat
and then install gem
PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH" gem install rmagick -v '2.13.2'
I had a similar issue with running
$ gem install rmagick
then check the version by typing
$ 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 again.
this worked for me try
if the above solution doesnt work then try following command
sudo apt-get install libmagickwand-dev
this will help i hope.
The only thing that worked for me on OSX El Capitan (10.11.6) was cloning this repository:
https://github.com/zagros/imagemagick-rmagic-el-captian
And following compile steps for each library described on that github page, but with slight modification.
The imagemagick itself in stuff folder is already compiled and lacks configure script, so I took other image magick from stuff sierra extracted it and compiled, installed and after that gem install rmagick worked.

Problems getting ruby-libvirt extensions to compile Mountain Lion

I bought a new Mac this week and have had big problems getting this gem installed. It was never a problem on my old Mac but seems to be particularly difficult on this one.
I have installed libvirt via Homebrew, Xcode4.4 (with command line tools) and gcc4.2. I have symlinked to make gcc4.2 the default compiler.
gem install ruby-libvirt -v '0.4.0' fails because it cannot find the headers
If I pass in the paths to the headers and libraries, like so:
ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/0.9.11.3/include/ --with-libvirt-lib=/usr/local/Cellar/libvirt/0.9.11.3/lib/
, it compiles just fine but fails when linking with the following errors:
linking shared-object _libvirt.bundle
ld: library not found for -lruby.1.9.1
collect2: ld returned 1 exit status
make: *** [_libvirt.bundle] Error 1
I have installed Ruby 1.9.3 via RVM and haven't had any troubles installing other native extensions, so I cannot see why it fails to find the ruby libraries in this case.
Does anyone have any ideas? Help would be much appreciated.
I built ruby-libvirt-0.4.0/ext/libvirt by proving external libvirt installed using brew.
Here is what I did to successfully install libvirt.
brew install libvirt
ruby extconf.rb --with-libvirt-include=/usr/local/include/libvirt --with-libvirt-lib=/usr/local/lib/libvirt
gem install ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/1.1.4/include/libvirt --with-libvirt-lib=/usr/local/Cellar/libvirt/1.1.4/lib
Hope this helps.
To install the gem you need to install the libvirt libraries. Using 'Homebrew' (a package manager for mac) :
brew install libvirt
bundle install
The exact error you got might have been:
An error occurred while installing ruby-libvirt (0.4.0)
I have finally solved this. It turns out that the command line tools were not properly installed. The following line needs to be added to your .zshrc file (or whatever applies to your choice of shell):
export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH
You need only to install libvirt, before the bundle install.
brew install libvirt

Resources