无法在Mountain Lion上安装rmagick gem

3
注意:我的情况与此几乎完全相同:无法在Mountain Lion上安装pg宝石
我刚刚从Snow Leopard升级到Mountain Lion,Rails给了我很多问题,特别是尝试安装'rmagick'宝石。 我正在运行Ruby 1.9.3-p362和Rails 3.2.11。
  git:(master)  sudo gem install rmagick -v 2.13.1
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

        /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... yes

Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
         /opt/local/bin/Magick-config reports version 6.6.6 Q8 is installed in /opt/local
         /OPT/LOCAL/BIN/Magick-config reports version 6.6.6 Q8 is installed in /opt/local
         /USR/LOCAL/BIN/Magick-config reports version 6.8.0 Q16 is installed in /USR/LOCAL/Cellar/imagemagick/6.8.0-10
Using 6.6.6 Q8 from /opt/local.

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/sscirrus/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
/Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
    from extconf.rb:193:in `<main>'


Gem files will remain installed in /Users/sscirrus/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/sscirrus/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

  applyco git:(master)  brew install imagemagick --disable-openmp
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: imagemagick-6.8.0-10 already installed

  applyco git:(master)  apt-get install libmagick9-dev
zsh: command not found: apt-get

我已经尝试过以下步骤:
  • 使用命令行工具安装Xcode
  • 重新安装homebrew
  • 清除所有存储库的gem(包括Gemfile.lock)并运行bundle install
  • 重新安装bundler gem
  • 重新安装ImageMagick
然而,以上步骤均未解决我的问题。我在stackoverflow上寻找了答案,但仍然没有获得帮助。您能指点我正确方向吗?

我在这里遇到了同样的问题...但有一个区别,也许你的homebrew链接到另一个版本的Imagemagick。因此,即使安装了imagemagick-6.8.0-10,也无法找到它。尝试像brew unlink imagemagick然后brew link imagemagick,看看会发生什么。 你试过brew doctor吗? - iGallina
4个回答

2

我在为RoR 3.2.11在Mountain Lion上设置开发环境时遇到了与您相同的问题。显然,RMagick的最新版本(2.13.1)无法与ImageMagick的最新版本(6.8.2-0)协同编译。禁用openmp并从源代码构建就像魔术一样奏效。

brew uninstall imagemagick
brew install imagemagick --disable-openmp --build-from-source
gem install rmagick

我不需要编辑在http://blog.paulopoiati.com/2013/01/28/installing-rmagick-in-mac-os-x-mountain-lion-with-homebrew/中描述的brew配方,但这可能是尝试的下一步。


1

1
这可能是权限问题,请尝试运行。
sudo chown -R `whoami` /usr/local

然后再试一次。


这应该是经过验证的答案。 - Mr_Pouet

1

第一次尝试在Rails 3中使用Paperclip时,我遇到了相同的问题。为了总结之前的答案,以下是对我有效的方法:

sudo chown -R `whoami` /usr/local
brew link --overwrite imagemagick

谢谢!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接