Gem 求助!在 Windows 下安装 “rmagick” 失败,已经安装了 Windows 版本的 ImageMagick,还是一样报错

lgor · 2017年08月10日 · 最后由 zhangkaizhao 回复于 2017年08月12日 · 3679 次阅读

执行“bundle install”时报错:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
D:/develop/Ruby23-x64/bin/ruby.exe -r ./siteconf20170810-1028-1n1pw1i.rb
extconf.rb
*** 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=D:/develop/Ruby23-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version
(Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection.
Results logged to
D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/rmagick-2.16.0/gem_make.out

An error occurred while installing rmagick (2.16.0), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.

In Gemfile:
  rmagick

然后我在网上找了一些资料,说是要先安装“ImageMagick”,我下载安装之后,执行 gem install rmagick -- '--with-opt-dir="C:/Program Files/ImageMagick-7.0.6-Q16"'还是报错:

Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir="C:/Program Files/ImageMagick-7.0.6-Q16"'
This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
D:/develop/Ruby23-x64/bin/ruby.exe -r ./siteconf20170810-5204-f29kli.rb extconf.rb --with-opt-dir="C:/Program Files/ImageMagick-7.0.6-Q16"
*** 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=D:/develop/Ruby23-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection.
Results logged to D:/develop/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/rmagick-2.16.0/gem_make.out

尤其是这一句:

extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)

好像跟别人的不一样,但实在找不出哪里出错了,请大家帮忙看看,谢谢!

No such file or directory - identify

提示就是说 identify 这个找不到啊


还有,能不能不要这么玩,用 Windows 已经是给你自己挖个坑了,然后又是 ImageMagick, RMagick,RMagick 安装本身就是一件复杂的事情。你搜索到哪里资料,你确定是针对 Windows 环境的?

用 Linux 有那么难么?

huacnlee 回复

谁不想做简单的事解决问题呢,但作为小程序员,不是想要什么就什么的啊

去 windows store 装一个 linux 子系统就可以了: https://www.microsoft.com/en-us/store/p/ubuntu/9nblggh4msv6

推荐 rubyinstaller2 : https://github.com/oneclick/rubyinstaller2

C 扩展的编译支持舍弃了 rubyinstaller 使用的 DevKit 而改用 msys2 了:

Install gems with C-extensions and additional library dependencies

The base MSYS2 setup includes compilers and other build tools, but doesn't include libraries or DLLs that some gems require as their dependencies. Fortunatelly many of the required libraries are available through the MSYS2 repositories. They can be installed per ridk exec pacman -S mingw-w64-x86_64-libraryname similar to apt-get on Linux. Exchange the prefix mingw-w64-x86_64 by mingw-w64-i686 for the 32-bit RubyInstaller.

For instance these popular gems can be installed like so from the source gem:

To install sqlite3 gem:
  ridk exec pacman -S mingw-w64-x86_64-sqlite3
  gem install sqlite3 --platform ruby
To install nokogiri gem:
  ridk exec pacman -S mingw-w64-x86_64-libxslt
  gem install nokogiri --platform ruby -- --use-system-libraries

之前我就用这个解决了 nokogiri 在 Ruby 2.4 上的安装编译失败问题。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号