ruby - Rmagic 不适用于 Rails3

标签 ruby ruby-on-rails-3 rmagick

我的 Rmagic 不工作

ruby -v

ruby 1.8.7(2010-01-10 补丁级别 249)[i386-mingw32]

rails -v

轨道 3.0.0.beta4

irb

require rubygems

正确

require rmagick

正确

但是,我放了流程代码:

gem 'rmagick', :require => false

错误:

checking for Ruby version >= 1.8.5... 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=C:/Ruby/bin/ruby


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/source.rb:100:in `install'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:55:in `run'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:44:in `run'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:8:in `install'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/cli.rb:217:in `install'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/task.rb:22:in `send'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/task.rb:22:in `run'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor.rb:246:in `dispatch'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/base.rb:389:in `start'
        from C:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.0/bin/bundle:13
        from C:/Ruby/bin/bundle:19:in `load'
        from C:/Ruby/bin/bundle:19

请帮助我,谢谢!

最佳答案

MagickWand.h 是 ImageMagick 的一部分而 RMagick 安装程序找不到它。看来您需要在系统上安装 ImageMagick,或者如果安装了它,则需要将库添加到 gem 安装程序可以看到的路径。如果您的系统上没有安装 ImageMagick 或 GraphicsMagick,RMagick 将无法工作。

更新的答案 由于您使用的是 Windows,因此您需要手动下载 gem 并进行安装。安装常见问题解答说:

使用 rmagick-win32 gem。此 gem 与 ImageMagick Windows 安装程序的副本捆绑在一起,因此您无需下载自己的副本。从 RubyForge 上的 RMagick 项目页面下载 rmagick-win32 gem,将其解压缩到一个临时目录,然后按照您将在包中找到的 README.html 文件中的说明进行操作。

http://rubyforge.org/projects/rmagick/

我想你可能想卸载你已经安装的 imagemagick 版本,以防发生任何冲突。手动安装 gem 后,您应该可以将其放入 Gemfile 并进行捆绑安装。由于没有在 Windows 上使用过 rmagick,我不确定您是将 gem 称为“rmagick”还是“rmagick-win32”。手动安装 gem 后,您可能可以通过运行“gem list”命令来解决这个问题。查看出现了哪一个并将其放入您的 Gemfile,以便它可以找到已安装的版本。Bundler 将使用此 gem 而不是尝试安装新的。

关于ruby - Rmagic 不适用于 Rails3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3745080/

相关文章:

ruby-on-rails - 本地主机上的Honeybadger和Ruby on Rails

ruby - 模块类 << 自常量

javascript - 通过 jQuery 表单 railscasts 剧集以嵌套形式添加字段的问题

ruby-on-rails - 如何使用haml和rails设置数据属性?

image - 使用 rmagick 像在 Photoshop 中一样为图像着色

Ruby/RMagick 旋转和组合图像

ruby-on-rails - Heroku worker dyno 给出 R14 错误 - 内存管理问题 - rmagick 内存限制选项

ruby-on-rails - 编辑和测试现有 Ruby gem(即 Gollum)的最佳方法是什么?

ruby-on-rails - 如何从一个通用脚本运行多个 watir 脚本

ruby-on-rails-3 - rails 复杂的多对多查询