gem install rmagick 错误

3
我知道有许多关于这个错误的问题,但是我阅读了几篇教程和SO讨论,还是没有找到解决办法。
我试图安装rmagick(我想要安装用于Ruby on Rails的Spree电商,需要使用ImageMagick和rmagick)。
我正在使用Windows 7(64位),Ruby版本为2.1.5,Rails版本为4.2.1。我下载并安装了ImageMagick-6.9.1-2-Q16-x64-dll.exe(放在C:\ImageMagick中),我也安装了开发工具包Dev-Kit。
我按照Sumit Munot在这里建议的步骤ImageMagick Install Windows进行操作,但是在执行第6步时,我遇到了这些错误。
C:\Sites>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... 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=C:/RailsInstaller/Ruby2.1.0/bin/ruby
C:/RailsInstaller/Ruby2.1.0/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 C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'

        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1067:in `block i
n have_header'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in
 postpone'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone
'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking
_for'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1066:in `have_he
ader'
        from extconf.rb:37:in `configure_headers'
        from extconf.rb:17:in `initialize'
        from extconf.rb:474:in `new'
        from extconf.rb:474:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1
.0/gems/rmagick-2.15.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86
-mingw32/2.1.0/rmagick-2.15.0/gem_make.out

C:\Sites>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... 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=C:/RailsInstaller/Ruby2.1.0/bin/ruby
C:/RailsInstaller/Ruby2.1.0/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 C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'

        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1067:in `block i
n have_header'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in
 postpone'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone
'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking
_for'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1066:in `have_he
ader'
        from extconf.rb:37:in `configure_headers'
        from extconf.rb:17:in `initialize'
        from extconf.rb:474:in `new'
        from extconf.rb:474:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1
.0/gems/rmagick-2.15.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86
-mingw32/2.1.0/rmagick-2.15.0/gem_make.out

这是我的路径:C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.1.0\bin;C:\Ruby21\bin; 我需要添加什么到路径中吗?

(说明:该段文字讲述了一个路径,询问是否需要在路径中添加内容)

1
DEVKIT_HOME\bin 必须包含在 %PATH% 中。 - Aleksei Matiushkin
3
我也遇到了一些非常奇怪的问题。最近我只能建议你学习Linux,并仅在Linux主机上运行Ruby和尤其是Rails,因为它们是为此而设计的,并且在Linux上性能更好。 - davidb
看看这个是否有帮助:https://dev59.com/FFPTa4cB1Zd3GeqPn_Mt - Pramod Shinde
尝试这个:https://dev59.com/8W025IYBdhLWcg3wwo2m - inquisitive
2个回答

1

我也遇到了同样的问题,尝试了第二次。

  • 删除当前的ImageMagic文件夹和rmagick gem
  • 此处安装ImageMagick-6.7.9-3-Q16-windows-dll.exe,并在同一文件夹中安装ImageMagick-6.7.9-2-Q8-windows-static.exe(这些可以正常工作,而最新版本则不行)
  • 在你的控制台窗口中键入 set path=d:\ImageMagick;%path%
  • gem install rmagick -- '--with-opt-dir="d:\ImageMagick"'

我显然是将ImageMagick安装在d:\ImageMagick中,所以根据你的情况进行调整。 这适用于我的Ruby 1.9.3在Windows 7下,成功!


0

系统变量中将%DEVKIT_HOME%\bin设置到你的%PATH%中:

enter image description here


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