11

我面临在山狮中安装 rmagick 的问题。我已经安装了 Xcode 4.4 和开发者工具。仍然面临这个问题。

    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>'
4

11 回答 11

20

我今天早上刚更新到 Mountain Lion,遇到了 rmagick 麻烦。我在过去的某个时候通过自制软件安装了 ImageMagick,所以在通过 xcode 的首选项窗口安装新的命令行工具后,这对我有用。

brew update
brew uninstall ImageMagick
brew install ImageMagick
gem uninstall rmagick
gem install rmagick

我不必像上面提到的一些帖子那样对 gcc 变得时髦。

于 2012-10-08T19:25:01.553 回答
14

我终于解决了这个问题:

$ 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

解决方案来自https://coderwall.com/p/wnomjg

于 2012-12-31T03:53:26.343 回答
13

我也一样

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

按照https://gist.github.com/1860511中的说明进行操作

于 2012-07-26T22:55:05.213 回答
3

因此,在将我的 mac pro 更新为 Mountain Lion 之后,我的 ruby​​ 环境开始一个接一个地出现不同的错误。经过 1-2 小时的试错和谷歌搜索,这是我在 Rails 环境中修复我的 ruby​​ 的方法。

首先,我遇到了 ruby​​ env 错误。它没有检测到 git 命令,当我运行时,Bundler 因错误而尖叫foreman start

第 1 步Update XCode。获取最新的 Xcode 4.6 Mountain Lion 没有预先安装 ruby​​ 标头,因此您需要从 XCode 手动执行此操作。转到 Xcode 首选项/下载。

Install Command Line Tools

第2步: Install XQuartz

注销并再次登录。(您可能不需要这个,因为 imagemagick 公式已更新

第 3 步:现在您的 ruby​​ 环境将开始谈论 Imagemagick 错误执行以下操作:

brew update

brew uninstall imagemagick

brew install --fresh imagemagick

gem uninstall rmagick 2.13.2

gem install rmagick

在尝试了最后一个之后,现在它会给你这样的原生扩展错误

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.

第4步: sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

这应该可以解决 Mountain Lion 在升级后给您的所有问题。

跑吧bundle

于 2013-02-06T18:35:36.197 回答
1

这是我在几次尝试后如何让 RMagick 工作的快速总结。我觉得以下是获得它的最佳方法,而无需费心下载源代码压缩包和编译 - 把它留给专家

  • 你需要为 gcc/g++ 等安装 Xcode 和命令行工具。命令行工具不会随 Xcode 自动安装,去Preferences安装它
  • 接下来安装Macport
  • 也安装Homebrew
  • 确保您已安装 X11 服务器 - 如果未安装 - sudo port install -v xorg-server。我使用-v选项,因为它是一个长时间的安装,你可能想知道它是在做某事还是只是挂起
  • 安装 pkgconfig -sudo brew install pkgconfig
  • 现在是安装 ImageMacick 的时候了——sudo port install -v ImageMagick
    不要使用 brew 来安装 ImageMagick——它不会正确安装所有依赖项和委托。
  • 一旦安装了 ImageMagick - 设置DISPLAY环境变量 - export DISPLAY=:0.0- 最好还是把它放在你的.profile
  • 现在测试你的 ImageMagick 安装
  • 启动 X11 服务器(安装 X11 服务器后,它会出现在您的应用列表中)
  • 从命令行运行 -$convert logo: logo.gif; identify logo.gif; display logo.gif应该会弹出一个窗口显示logo.gif
  • 还从命令行运行命令 - $convert -list configure | grep -i delegates。它应该输出以下内容
    DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma png tiff x11 xml zlib

  • 现在你应该设置为运行 sudo gem install RMagick

成功安装 RMagick 后 - 检查它的安装位置,转到其中的示例目录并运行一些程序。

于 2013-02-14T08:20:31.700 回答
1

尝试更改路径,使 /usr/local/bin 在 /usr/bin 之前插入。我找到了这个正在运行的 brew doctor ,它让我完成了 imagemagick 的编译。

于 2012-07-31T17:20:37.247 回答
1

没有解决方案对我有用,最终我跑了brew doctor,发现我需要将 imagemagick 与brew link --overwrite imagemagick

于 2014-07-05T12:27:50.300 回答
1

我有类似的问题,但在 El Captain。在这里更好地解释。安装 xcode 命令行工具后修复:

xcode-select --install
于 2016-02-17T14:34:02.293 回答
0

我刚刚安装了 rmagick 2.13.2,这个问题就消失了。

于 2013-07-13T18:30:32.930 回答
0

您需要安装 XCode 4.4、命令行工具等。在此处查看完整列表:http: //tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html

于 2012-07-27T03:07:15.113 回答
0

我发现我的解决方案是上面列出的步骤的组合,在http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html和这里http://robots .thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion,尽管我不必执行任一帖子中列出的所有步骤。但我确实需要从 XCode 安装命令行工具,前几次我错过了这个细节。我还必须使用自制软件安装 gcc-4.2,并在我的 bin 目录中创建指向该安装的符号链接。

我可能会对不同编译器的情况感到困惑,但我会谨慎使用符号链接 /usr/bin/gcc 到 /usr/bin/gcc-4.2 (这又可能是由安装的 gcc-4.2 的链接自制)。在我意识到我需要安装命令行工具之前,我曾尝试创建该符号链接,然后我开始看到其他 gem 构建失败。安装命令行工具解决了这些问题——我相信 xcode 命令行工具使它成为 llvm-gcc-4.2 的符号链接。

于 2012-07-27T04:37:14.307 回答