检查ImageMagick版本是否大于等于6.4.9...不是。无法安装RMagick 2.13.4。您必须拥有ImageMagick 6.4.9或更高版本。

15

我在安装rmagick过程中遇到了困难。我的项目使用ruby on rails框架进行开发。我在gemfile中包含了rmagick gem。但是我遇到了以下错误信息:

checking for ImageMagick version >= 6.4.9... no
Can't install RMagick 2.13.4. You must have ImageMagick 6.4.9 or later.

我已经使用brew安装了imagemagick:

 imagemagick-6.8.9-8 already installed

ImageMagick文件夹位于/usr/local/Cellar目录下。

在我的终端中:

Zoulfias-iMac:Myapp zoulfiahall$ rvm use ruby-2.0.0-p481

Using /Users/zoulfiahall/.rvm/gems/ruby-2.0.0-p481
Zoulfias-iMac:Myapp zoulfiahall$ sudo gem install rmagick

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

/Users/zoulfiahall/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... no
Can't install RMagick 2.13.4. You must have ImageMagick 6.4.9 or later.

*** 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/zoulfiahall/.rvm/rubies/ruby-2.0.0-p481/bin/ruby

extconf failed, exit code 1

Gem files will remain installed in /Users/zoulfiahall/.rvm/rubies/
ruby-2.0.0-  p481/lib/ruby/gems/2.0.0/gems/rmagick-2.13.4 for inspection.
Results logged to /Users/zoulfiahall/.rvm/rubies/
ruby-2.0.0-  p481/lib/ruby/gems/2.0.0/extensions/x86_64-darwin-13/
2.0.0-static/rmagick-2.13.4/gem_make.out

非常感谢您的咨询。我们很乐意为您提供帮助。

9个回答

42

这对我在Ubuntu上运行成功。

$ sudo apt-get install imagemagick
$ sudo apt-get install libmagickwand-dev

现在请再试一次。

$ bundle install

1
谢谢您发布这个。它可以工作,但我还需要使用命令安装ruby-rmagick#apt install ruby-rmagick - mohit
如果可能的话,请尝试解释为什么我们需要安装这些库才能使ImageMagick正常工作。类似地,在其他情况下也是如此。 - Sunil Kumar
@RememberWhyYouStarted 我不知道为什么需要它。似乎该库依赖于开发库而不仅仅是生产二进制文件。我不知道为什么,只知道它能工作。 - justin.m.chase

15

在 macOS 上运行 gem install rmagick -v 2.13.4 时,我遇到了相同的问题。

解决方法是rmagick安装程序 (gems/rmagick-2.13.4/ext/RMagick/extconf.rb) 检查convert 的输出以确定IM版本。 如果返回的不是正确的版本(或者像我的情况一样完全损坏),则rmagick将无法安装。

我通过Homebrew安装了ImageMagick 6,这解决了我的问题。 这段代码将安装IM,将其添加到您的路径中,并显式地指向IM6运行安装程序。

$ brew install imagemagick@6
$ echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick -v 2.13.4

祝好运!


4

如果您使用brew install imagemagick@6安装了ImageMagick

在运行bundle install之前,请执行以下操作:

export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"

4

今天我也遇到了同样的问题。

问题的原因是rmagick版本过旧,而且该gem包没有经常更新。

我想为那些不介意使用较旧版本imagemagick的人提供解决方案。(我相信它可以高达6.5.9-10)

  1. 卸载所有组件的imagemagick:

    brew uninstall --force imagemagick

  2. 通过在命令末尾添加-ruby186来安装较旧版本的imagemagick

    brew install imagemagick-ruby186

  3. 安装rmagick :)

    gem install rmagick

  4. 享受吧!


1

我刚遇到了同样的问题。尝试卸载ImageMagick,然后重新安装:

brew uninstall --force imagemagick
brew install imagemagick

然后安装rmagick。这对我有用。

1
这是最简约和直接的解决方案,对我来说效果很好。我建议其他人在尝试其他方法之前先尝试这个。 - adrianmcli

0

0

这个方法解决了我在MacOS 10.14 Mojave中的问题。

brew install pkg-config
PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick@6/6.9.11-0/lib/pkgconfig gem install rmagick -v 2.16.0

0

我在https://github.com/rmagick/rmagick/issues/126提交了一个类似问题的错误报告。

我正在使用Debian sid 的crunchbang linux。

看起来你正在使用OSX,如果你还没有提交错误报告的话,请考虑提交你自己的错误报告。


-1
brew uninstall pkg-config
brew install pkg-config
brew unlink pkg-config
brew link pig-config

sudo gem install rmagick

这对我有用。


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