草庐IT

ruby-on-rails - gem install rmagick -v 2.13.1 错误 Failed to build gem native extension on Mac OS 10.9.1

coder 2025-07-22 原文

我已经通过提供 MagickWand.h 的路径尝试了一切,我安装了命令工具。谁能帮帮我?

$ 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/ghazanfarali/.rvm/rubies/ruby-1.8.7-p357/bin/ruby extconf.rb checking for Ruby version >= 1.8.5... yes checking for /usr/bin/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... no checking for sys/types.h... no checking for wand/MagickWand.h... no

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 --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/ghazanfarali/.rvm/rubies/ruby-1.8.7-p357/bin/ruby

Gem files will remain installed in /Users/ghazanfarali/.rvm/gems/ruby-1.8.7-p357/gems/rmagick-2.13.1 for inspection. Results logged to /Users/ghazanfarali/.rvm/gems/ruby-1.8.7-p357/gems/rmagick-2.13.1/ext/RMagick/gem_make.out "

最佳答案

我强烈建议使用像 HomeBrew 这样的东西,如果您还没有管理 OSX 包。还有其他选择,包括 MacPorts。

RMagic 只是一个 ruby​​ 接口(interface),带有用于底层 ImageMagic 包的 ruby​​ 绑定(bind)。

我会确保安装了最新的 imagemagick:

brew install imagemagick

或者,如果已经安装:

brew upgrade imagemagick

或者,根据 this answer :

# install latest command line tools via xcode     
# make sure you have the latest homebrew with the latest packages 
brew update
# uninstall imagemagick and then reinstall to make use updated compiler
brew uninstall imagemagick
brew install imagemagick
# uninstall rmagick then reinstall to ensure native extensions are built against
# latest imagemagick
gem uninstall rmagick
gem install rmagick # or bundle

此外,您可以运行:

brew doctor

确定可能影响这些包构建的任何问题。

更新


两种方法:

  1. RMagick最近更新以修复与最新 ImageMagick 相关的构建问题。使用版本 2.13.2。根据 RMagick 自述文件: 此版本将修复由于 ruby​​ 1.9.3 和 ImageMagick 6.8+ 而导致的安装问题。

  2. 可能是更好的方法。将 rmagick 替换为 mini_magick因为 mini_magick 正在积极开发中,而 rmagick 还没有。 Imagemagick 也在积极开发中,因此随着 API 的变化,RMagick 过时的 API 将变得越来越陈旧。

关于ruby-on-rails - gem install rmagick -v 2.13.1 错误 Failed to build gem native extension on Mac OS 10.9.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023150/

有关ruby-on-rails - gem install rmagick -v 2.13.1 错误 Failed to build gem native extension on Mac OS 10.9.1的更多相关文章

随机推荐