简体   繁体   中英

Can't install RMagic and Nokogiri on OS X 10.10 Yosemite

Had to install Yosemite to fix issues with Wi-Fi but now installing rmagick fails. I have tried everything from every post on StackOverflow and Github but the install still failing.

I am using ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] installed via rbenv

$ brew remove imagemagick
$ brew install imagemagick --disable-openmp
$ cd /usr/local/Cellar/imagemagick/6.8.9-1/lib
$ ln -s libMagick++-6.Q16.3.dylib libMagick++.dylib
$ ln -s libMagickCore-6.Q16.dylib libMagickCore.dylib
$ ln -s libMagickWand-6.Q16.dylib libMagickWand.dylib
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.9-1/include/ImageMagick-6/ gem install rmagick

But failed:

Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    /Users/pain/.rbenv/versions/2.1.1/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... 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
    --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/pain/.rbenv/versions/2.1.1/bin/ruby
/Users/pain/.rbenv/versions/2.1.1/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/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
    from extconf.rb:194:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/pain/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/pain/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/rmagick-2.13.2/gem_make.out

Any suggestions would really help. Thanks.

PS To my horror after running gem cleanup I realized that no matter what I do, I can't install nokogiri as well...

I was just having this same issue on OSX 10.10 (and went through most of the steps you went through). If you installed ruby with the CC=clang prefix, navigate to /usr/bin and run:

sudo unlink gcc-4.2
sudo mv gcc gcc-foo
sudo ln -s clang gcc

If you're still getting issues, I might try sudo ln -s clang gcc-4.2

Following suggestion on Github I have removed gcc 4.2 and rebuilt Ruby. That fixed everything for rmagick and nokogiri .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM