ruby-on-rails - 如何在 Windows 10 上安装 rmagick

标签 ruby-on-rails ruby rubygems rmagick

我正在尝试安装一个依赖 rmagick 作为 Windows 10 依赖项的 gem。但每次我尝试安装它时,都会出现此错误:

ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160126-6648-ks1v6.rb extconf.rb --  with-opt-dir=C:/ImageMagick
*** 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=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:110:in ``': No such file or directory - identify -version    (Errno::ENOENT)
    from extconf.rb:110:in `configure_compile_options'
    from extconf.rb:16:in `initialize'
    from extconf.rb:517:in `new'
    from extconf.rb:517:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-   x64/lib/ruby/gems/2.2.0/gems/rmagick-2.15.4 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64- mingw32/2.2.0/rmagick-2.15.4/gem_make.out
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=C:/ImageMagick'
This could take a while...

我什至安装了 gem imagemagick,但它不允许我安装 rmagick。你应该如何在 Windows 10 上安装 rmagick?

最佳答案

您必须使用正确版本的 ImageMagick,并且在安装 gem 时必须引用它:

这是 gem :

gem install rmagick --platform=ruby -- '--with-opt-dir="[path to ImageMagick]"'

更新

这是一个 good reference

安装步骤如下:

  1. Download & 安装 ImageMagick

enter image description here

RMagick 的较新版本曾经存在问题;我们安装了 6.9.2 版本,它在 Win10 x64 上运行:

enter image description here

您需要确保勾选了上述两个复选框(C headers && system PATH)。 gem 使用 header 进行编译(可能是您出错的原因); PATH 用于从 cmd 调用 ImageMagick。

您还需要确保...

--

  1. 安装 gem

mysql2 等,您需要确保引用已安装的库才能安装 rmagick:

gem install rmagick --platform=ruby -- --with-opt-lib="c:/path_to_image_magick/lib" --with-opt-include="c:/path_to_image_magick/include"

这可能需要一段时间,但应该安装。

关于ruby-on-rails - 如何在 Windows 10 上安装 rmagick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35026112/

相关文章:

ruby-on-rails - Rails - 使用 axlsx gem (Keep MVC) 将记录导出到可下载的 excel 文件

ruby-on-rails - 如何解决捆绑安装 rake 错误和 Gem::RemoteFetcher::FetchError

ruby-on-rails - 如何通过关联在使用 has_many 的模型上使用 ActiveAdmin?

ruby-on-rails - 如何将 Ruby on Rails 网站预编译为生产模式?

javascript - Bootstrap modals - 在更新模态窗口的大小/内容时更新背景阴影 mask

ruby-on-rails - 服务器启动时如何修复 "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5"

ruby-on-rails - 使用不带 gem 的 devise,我可以简单地复制文件吗?

ruby-on-rails - 恢复生产数据库备份的一部分

ruby-on-rails - block 给定?在 erb 模板中总是返回 true

ruby-on-rails - 返回 : Creating a method with a parameter