Installing nokogiri after a Mavericks upgrade -- entities.c is missing? - nokogiri

I'm running into the same problem most people are running into with nokogiri install on post-Mavericks upgrade machine.
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libx/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:278:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `chdir'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `execute'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:65:in `configure'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:108:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:119:in `call'
from extconf.rb:119:in `block in <main>'
from extconf.rb:109:in `tap'
from extconf.rb:109:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/extensions/x86_64-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
My configure.log shows the following error:
configure: error: cannot find sources (entities.c) in /usr/local/lib/node_modules/npm or ..
I've tried installing/reinstalling/unlinking/relinking libxml2, libxslt.
Any other tips? Thanks!

Installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before installing the gem did the trick for me.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

Had the exact same problem. I latched onto why is it looking for (entities.c) in
/usr/local/lib/node_modules/npm or ..
I'm no expert but npm probably doesn't have make files in it.
I got nokogiri to install by removing npm from my ~/.bash_profile (the other place to check might be ~/.profile). Here was how my .bash_profile looked:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/node_modules/npm:/usr/local/mysql/bin:$PATH"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
source ~/.profile
You can see npm in the first line, I just deleted that, reloaded my terminal (so it stopped looking in npm directory for stuff) and did sudo gem install nokogiri AND IT WORKED :)!!!
As a side note npm commands seem to be working so I don't know why I had that path in my .bash_profile
Hope this helps, first answer on SO.

Here is my solution for Yosemite and libxml2 installed via brew
gem install nokogiri -v '1.6.5' -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2

Related

Cant install rails

I have a new set up, and I keep getting an error when I am trying to install rails. I have used RVM to use ruby 2.2.2, and I have checked through the config files.
I have followed various tutorials. I have uninstalled gcc ( though i may reinstall xcode )
and I have gone through various tutorials on how to install this
gem install rails [9:00:49]
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/rrobin008c/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20150812-28205-1wdgrip.rb extconf.rb
checking if the C compiler accepts -O2 -arch x86_64... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-apple-darwin14.4.0/ports/libxml2/2.9.2... OK
Running patch with /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK
Running 'configure' for libxml2 2.9.2... ERROR, review '/Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-apple-darwin14.4.0/ports/libxml2/2.9.2/configure.log' to see what happened.
*** 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/rrobin008c/.rvm/rubies/ruby-2.2.2/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:66:in `configure'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:109:in `cook'
from extconf.rb:278:in `block in process_recipe'
from extconf.rb:177:in `tap'
from extconf.rb:177:in `process_recipe'
from extconf.rb:475:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/rrobin008c/.rvm/gems/ruby-2.2.2/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Manually install nokogiri
gem install nokogiri -v VERSION_YOU_WANT -- --use-system-libraries
Check out "nokogiri gem installation error".
Before you run bundle install, run:
bundle config build.nokogiri --use-system-libraries
or
gem install nokogiri -- --use-system-libraries
After that you can run:
bundle install
For other bugs read the Nokogiri install documentation.
I went through the various tutorials and my output looked like this:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/rrobin008c/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150812-2574-6ejap3.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling breakpoint.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [breakpoint.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/rrobin008c/.rvm/gems/ruby-2.2.1/gems/byebug-5.0.0 for inspection.
Results logged to /Users/rrobin008c/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/byebug-5.0.0/gem_make.out
An error occurred while installing byebug (5.0.0), and Bundler cannot continue.
Make sure that `gem install byebug -v '5.0.0'` succeeds before bundling.
The significant part is
make: /usr/bin/gcc-4.2: No such file or directory
After this I asked:
$which gcc
/usr/bin/gcc
Follow "OS X Mountain Lion: gcc-4.2 No such file or directory" and everything should work after that.
I would recommend running
brew doctor
rvm reinstall
rvm reinstall (ruby version here)
gem pristine all
sudo gem install rails
If you get to many error best thing to do is remove rails and ruby completely
first type this
tarun#tarun:~$ which ruby
/home/tarun/.rbenv/shims/ruby
tarun#tarun:~$ which rails
/home/tarun/.rbenv/shims/rails
then copy the path and use this command to remove the file
rm -rf /home/tarun/.rbenv/shims/ruby
rm -rf /home/tarun/.rbenv/shims/rails
and same way you can check which rbenv and which rvm and remove by using this same method.
And use
grep -rl rails
grep -rl ruby
this will show path of all files which have rails keyword.So that you can know that have you removed rails and ruby completely.
And follow steps given here to reinstall it
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04

Nokogiri install on a Redhat VM fails

I'm trying to setup a new Redhat VM that will run my Redhat Ruby on Rails application.
I am trying to bundle install and it's not working. It keeps telling me to install Nokogiri, but I do install it but I still get the error.
Here is how I installed Nokogiri
$ sudo gem install nokogiri -v 1.5.11
Building native extensions. This could take a while...
Successfully installed nokogiri-1.5.11
1 gem installed
Then, in my Rails app I do bundle install and I get this error:
Installing nokogiri (1.5.11)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for libxml/parser.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=/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
from extconf.rb:116:in `<main>'
Gem files will remain installed in /home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11 for inspection.
Results logged to /home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.5.11), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.5.11'` succeeds before bundling.
Thoughts?
Following the guide here: http://nokogiri.org/tutorials/installing_nokogiri.html worked for my install using Homebrew 0.9 below are what they recommend for Red Hat.
Red Hat / CentOS
The easiest way to get Nokogiri installed on CentOS and RHEL seems to be the EPEL repository which contains a prebuilt nokogiri package. To use it, install the appropriate epel-release package for your OS, then run:
sudo yum install -y rubygem-nokogiri
To install using gem install is somewhat more complicated because of the age of the packages available from the central repositories. If you have rubygems installed, you may be able to install nokogiri via gem install. If you run intro problems, try installing these packages as well.
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
CentOS 5 (and RHEL5) come installed with libxml 2.6.26 which, while not as offensively out-of-date as Mac Leopard, is still pretty damn old (released June 2006) and has known issues.
If you’re affected by any known bugs or are seeing odd behavior, you may want to consider uninstalling the RPMs for libxml2 and libxslt, and building them from source.
sudo yum remove -y libxml2-devel libxslt-devel
download the most recent libxml2 and libxslt from ftp://xmlsoft.org/libxml2/
./configure ; make ; sudo make install
Then install nokogiri specifying the libxml2 and libxslt install directories:
sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib
--with-xml2-include=/usr/local/include/libxml2
--with-xslt-lib=/usr/local/lib
--with-xslt-include=/usr/local/include
(Note that, by default, libxslt header files are installed into the root include directory, but libxml2 header files are installed into a subdirectory thereof named libxml2.)
Or, you know, whatever directories into which you installed libxml and libxslt. Good luck.
Here is how I installed nokogiri
$ sudo gem install nokogiri -v 1.5.11
...
/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
You used sudo to install Nokogiri when you're using a personal RVM sandbox. Don't do that. The RVM directions for installing gems specifically says:
DO NOT use sudo...
to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)
Next:
checking for libxml/parser.h... *** extconf.rb failed ***
Looks like you're missing the devel package for libxml.
try accessing the mkmf.log file and see what information is listed in there. I had a similar issue on Mac OS and I remember having to delete a file because it was corrupted.
Struggled for hours with this error, finally what I needed was:
yum install cmake
cheers
On CentOS the missing compiler environment was the cause for my gem problem:
yum install gcc
yum install cmake
yum install ruby-devel

rails cannot install nokogiri w Mavericks & rbenv

running OSX 10.9.4 and XCode 5.1.1, I switched recently from rvm to Rbenv, so I need to reinstall some gems, not a big deal, but...
I am stuck w Nokogiri gem installation, even after downloading and installing october version of the XCode command line tool and running :
sudo xcode-select -s /Library/Developer/CommandLineTools/
I also installed libxml2 libxslt w brew
I am still getting an error, is there any way to solve this issue ?
yves$ gem install nokogiri
Building native extensions. This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/yves/.rbenv/versions/2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.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/yves/.rbenv/versions/2.1.2/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
from extconf.rb:103:in `have_iconv?'
from extconf.rb:148:in `block (2 levels) in iconv_prefix'
from extconf.rb:90:in `preserving_globals'
from extconf.rb:143:in `block in iconv_prefix'
from extconf.rb:120:in `each_iconv_idir'
from extconf.rb:137:in `iconv_prefix'
from extconf.rb:427:in `block in <main>'
from extconf.rb:161:in `block in process_recipe'
from extconf.rb:154:in `tap'
from extconf.rb:154:in `process_recipe'
from extconf.rb:422:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3 for inspection.
Results logged to /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3/gem_make.out
when installing libxml2 libxslt I got a warning , it may interfere with the nokogiri installation ?
yves$ brew install libxml2 libxslt
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libxml2-2.9
######################################################################## 100.0%
==> Pouring libxml2-2.9.1.mavericks.bottle.1.tar.gz
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/libxml2/lib
CPPFLAGS: -I/usr/local/opt/libxml2/include
what should i do next ? thanks for your advices
I got the same error a few weeks ago. This is how I solved it:
You'll have to install the broken libraries manually. Use Homebrew, which is a package manager for OS X. Make sure you update first brew update, then install the libraries:
brew install libxml2 libxslt
brew link libxml2 libxslt
You may have to install libiconv from source:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
And then you should be able to install the gem.
Quoted from documentation here:
http://nokogiri.org/tutorials/installing_nokogiri.html#homebrew_09
You may also need to run rbenv rehash after installing the libraries.
I have found the solution on one of the forums:
https://github.com/sparklemotion/nokogiri/issues/1111
After almost a week of searching this finally did the trick:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri -- --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
GL
I got the same issue few days ago and this thread helped me
https://github.com/sparklemotion/nokogiri/issues/1111
Finally the command which worked for me
gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

rvm install 1.9.3 leading to ImageMagick installation issue

I was using Ruby 1.9.2 for my RoR 3.2.11 project
All worked fine until I had to upgrade to Ruby 1.9.3 because a gem required it.
By the same occasion I tried to make good use of RVM.
Installed ruby 1.9.3
rvm install 1.9.3 -C --with-openssl-dir=$HOME/.rvm/usr
Created .rvmrc
cd ./my_project/
rvm --create --rvmrc 1.9.3#project
Cleaned up my global gemset
rvm gemset empty
cd into my project and run installed gems
bundle
Error log
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-4.2... yes
checking for Magick-config... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/usr/local/ImageMagick/bin/Magick-config reports version 6.7.3 Q16 is installed in
/usr/local/bin/Magick-config reports version 6.7.1 Q16 is installed in /usr/local/Cellar/imagemagick/6.7.1-1
Using 6.7.3 Q16 from .
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:194:in `<main>'
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#my_project/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.
At first sight, it looks like I have 2 installations of ImageMagick and that I could spare one.
So my first question would be how to uninstall clean ImageMagick version 6.7.1 Q16?
and of course if there is something else I could try to solve this issue.
ADDITIONAL INFO about packages installed
I know that MacPort and Brew don't work well together but I always been worried about removing MacPort in its entirety. Could that be the problem?
port list | grep magick
p5-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.8-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.10-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.12-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.14-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.16-perlmagick #6.8.6-0 perl/p5-perlmagick
php-gmagick #1.1.2RC1 php/php-gmagick
php53-gmagick #1.1.2RC1 php/php-gmagick
php54-gmagick #1.1.2RC1 php/php-gmagick
php55-gmagick #1.1.2RC1 php/php-gmagick
php-imagick #3.1.0RC2 php/php-imagick
php53-imagick #3.1.0RC2 php/php-imagick
php54-imagick #3.1.0RC2 php/php-imagick
php55-imagick #3.1.0RC2 php/php-imagick
php-magickwand #1.0.9-2 php/php-magickwand
php53-magickwand #1.0.9-2 php/php-magickwand
php54-magickwand #1.0.9-2 php/php-magickwand
php55-magickwand #1.0.9-2 php/php-magickwand
php5-gmagick #1.1.2RC1 php/php5-gmagick
php5-imagick #3.0.1 php/php5-imagick
php5-magickwand #1.0.9-2 php/php5-magickwand
rb-rmagick #2.13.2 ruby/rb-rmagick
brew list
faac grc jasper lame libtiff libvpx pkg-config wget xvid
ffmpeg imagemagick jpeg libogg libvorbis little-cms theora x264 yasm
UPDATE
Remove MacPorts
sudo port -f uninstall installed
Uninstalled brew ImageMagick and installed it again with brew
Installed XCode latest version
and ran bundle, I do get a different message, C compiler missing ... argh, what should I do next, I am trying installing gcc with brew, but not sure that I am heading the right direction, please help:
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.
GCC 4.2
which gcc => /usr/bin/gcc
gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
echo $PATH
/bin;/usr/bin;/usr/sbin;/sbin;/usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429#global/bin:/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin:/Users/joel/.rvm/bin:/usr/bin;usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/local/ImageMagick/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/joel
NEW ERROR MESSAGE:
Installing json (1.8.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /opt/local/bin/gcc-apple-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/gems/json-1.8.0 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
It obviously looking for /opt/local/bin/gcc-apple-4.2 which I deleted recklessly while following these instructions to move from Macportd to homebrew :(
NOW INSTALLING MISSING PACKAGES with homebrew
brew install apple-gcc42
brew install libxml2
Couple things:
Remove MacPorts (you may list all things you installed with them and reinstall those with brew)
Remove imagemagick from homebrew
Install imagemagick again with brew
You're getting this error You have to install development tools first. which (I guess) means you need to install XCode command line tools.
Then bundle install should work!
you need to reinstall your ruby after removing the package manager you used to install it, the easiest way is to:
rvm reinstall 1.9.3-p429
In combination to the 2 first answers
brew uninstall imagemagick
and used http://cactuslab.com/imagemagick/
Then in my .bash_profile I set
PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig
C_INCLUDE_PATH=/opt/ImageMagick/include/ImageMagick-6
and finally
bundle

Issue with installing ImageMagick and rmagick on Mountain Lion

I am facing issues with installing rmagick in mountain lion. I have installed Xcode 4.4 and developer tools. Still facing this issue.
Installing rmagick (2.13.1) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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/mohit/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:193:in `<main>'
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `block in build_extensions'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `each'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `build_extensions'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:90:in `block in install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in `preserve_paths'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:89:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:in `with_build_args'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in `install_gem_from_spec'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:56:in `block in run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in `run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:12:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/cli.rb:220:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:in `dispatch'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in `start'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/bin/bundle:13:in `<top (required)>'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>'
I just updated to Mountain Lion this morning and had rmagick troubles. I had installed ImageMagick through homebrew at some point in the past, so this worked for me after installing the new commandline tools through xcode's preferences window.
brew update
brew uninstall ImageMagick
brew install ImageMagick
gem uninstall rmagick
gem install rmagick
I didn't have to get funky with gcc like some above posts mentioned.
I finally solved this using:
$ 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
The solution comes from https://coderwall.com/p/wnomjg
I was getting the same
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
did it as it says in https://gist.github.com/1860511
So after updating my mac pro to Mountain Lion, my ruby environment started screaming with different errors one after another.
After 1-2 hours of trial - error and googling, here is how I fixed my ruby on rails environment.
First I got ruby env errors.It was not detecting git commands and Bundler was screaming with
errors when I ran foreman start
Step1 : Update XCode. Get the latest one Xcode 4.6
Mountain Lion does not come with ruby headers installed before hand, so you need to do this manually from XCode. Go to Xcode Preferences/Downloads.
Install Command Line Tools
Step2: Install XQuartz
Logout and Login again. (You might not need this as imagemagick formula has been updated
Step 3: Now your ruby env would start speaking about Imagemagick errors
Do this:
brew update
brew uninstall imagemagick
brew install --fresh imagemagick
gem uninstall rmagick 2.13.2
gem install rmagick
After trying the last one, now it will give you native extension errors like this
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Gem files will remain installed in /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick- 2.13.1 for inspection.
Results logged to /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.
Step 4:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
This should fix all issues that Mountain Lion gifted you after the upgrade.
Just run bundle.
Try changing your path such that /usr/local/bin is inserter before /usr/bin. I found this running brew doctor and it allowed me to finish compiling imagemagick.
Here is a quick summary of how I was able to get RMagick work, after several tries. I feel the following is the best way to get it without going to the pains of downloading source tarballs and compilation - leave that to experts
You need to have Xcode and Command Line Tools installed for gcc/g++ etc. Command line tools do not get installed automatically with Xcode, go Preferences and install it
Next install Macport
Install Homebrew as well
Make sure you have X11 server installed - if not install it - sudo
port install -v xorg-server. I use -v option as it is a long install
and you might wonder whether it is doing something or just hanging
Install pkgconfig - sudo brew install pkgconfig
now it is time to install ImageMacick - sudo port install -v
ImageMagick do not use brew to install ImageMagick - it does not install all the dependencies and delegates properly.
once ImageMagick is installed - set DISPLAY env variable - export DISPLAY=:0.0 - better still put it in your .profile
Now test your ImageMagick installation
start X11 server (after X11 server installation it is will there in
your App List)
from command line run - $convert logo: logo.gif; identify logo.gif; display logo.gif - it should pop up a window displaying logo.gif
also run a command from command line - $convert -list configure | grep -i delegates. It should output the following DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma png tiff x11 xml zlib
Now you should be set to run
sudo gem install RMagick
After RMagick is installed successfully - check where it is installed, go to examples directory within and run some of the programs.
No solutions were working for me, eventually I ran brew doctor and discovered that I needed to link imagemagick with brew link --overwrite imagemagick
I had similar issue but on El Captain. Better explained here.
Fixed after installing xcode command-line tools:
xcode-select --install
You need to install XCode 4.4, command line tools, etc. Check out the full listing here:
http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html
I found the solution for me was a combination of the steps listed above, at http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html and here http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion, although I didn't have to do all the steps listed in either post. But I did need to install the command line tools from XCode, I missed that detail the first few times. I also had to install gcc-4.2 using homebrew, and make a sym link to that installation in my bin directory.
I could be confused about what's going on with the different compilers, but I would be cautious about sym linking /usr/bin/gcc to /usr/bin/gcc-4.2 (which may in turn be a link to gcc-4.2 installed by homebrew). Before I realized I needed to install the command line tools, I had tried making that sym link and then I started seeing other gem build failures. Installing the command line tools fixed those issues - I believe the xcode command line tools made it a sym link to llvm-gcc-4.2.
I just installed rmagick 2.13.2 and this issue is gone.

Resources