0

I'm on windows and I downloaded and installed rmagick-win32 RMagick-2.12.0-ImageMagick-6.5.6-8-Q8 from here (http://rubyforge.org/frs/?group_id=12&release_id=42049) which I unzipped and installed using 'gem install rmagick'

When I try to run rails s, I get this error message

C:\Users\Me\Desktop\sample_app>rails s
←[31mCould not find gem 'rmagick (>= 0) x86-mingw32' in any of the gem sources l
isted in your Gemfile.←[0m
←[33mRun `bundle install` to install missing gems.←[0m

So I try to bundle install or bundle update then I get this (I took out the full list of gems to save space):

C:\Users\Me\Desktop\sample_app>bundle update

Fetching source index for https://rubygems.org/
Installing rmagick (2.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        C:/RailsInstaller/Ruby1.9.3/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/Ruby1.9.3/bin/ruby
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler
 failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'

        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:931:in `block in
 have_header'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:790:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:284:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:284:in `block in
 postpone'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:280:in `postpone
'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:789:in `checking
_for'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:930:in `have_hea
der'
        from extconf.rb:194:in `<main>'


Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9
.1/gems/rmagick-2.13.2 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rmagick-2
.13.2/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.2), and Bundler cannot continue.

Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

Then I downloaded rmagick 2.13.2 and put it into the same folder and ran "gem install rmagick -v '2.13.2' but I'm getting a failed ERROR: Failed to build gem native extension again

I am trying to get 2.13.2 installed but I can't find any information on this. Anyone know if that's the issue and how this can be fixed?

4

2 回答 2

1

Windows 上的 RMagick 很棘手。在过去的两年里,当我在 Windows 上时,我设法找到了两种解决方案来解决同样的问题。

简单的解决方案

将以下内容添加到您的 Gemfile。它还将考虑其他平台。

if RUBY_PLATFORM =~ /(win|w)32$/
  gem 'rmagick', '2.12.0', :path => 'vendor/gems/rmagick-2.12.0-x86-mswin32', :require => 'RMagick'
else
  gem 'rmagick', :require => 'RMagick'
end

然后,解压缩 gem 以vendors/gems/使用:

gem unpack rmagick-2.12.0-x86-mswin32.gem vendors/gems/

更好的解决方案

我发现可以在 Windows 上编译 RMagick gem。在遵循此解决方案之前,请确保您已安装DevKit 。

我创建了一个批处理文件,它将 ImageMagick 的目录映射到X:\并为命令提供参数gem,以了解在哪里可以找到构建 RMagick 所需的文件。这种映射是必要的,因为配置选项不知道如何处理路径中的空格。

您可以使用以下命令将 ImageMagick 的目录映射到X:\并编译和安装 gem。

subst X: "C:\Program Files (x86)\ImageMagick-6.7.6-Q16"
gem install rmagick --platform=ruby -- --with-opt-lib="X:\lib" --with-opt-include="X:\include"
subst X: /D

如果您安装了 6.7.6-Q16 以外的版本,或者您不在 64 位 Windows 上,则需要编辑路径。

使用此解决方案安装 gem 后,您现在应该可以gem 'rmagick', :require => 'RMagick'在 Gemfile 中进行捆绑。

于 2013-03-12T06:23:53.843 回答
0

在 Windows 上,您需要DevKit for Ruby 来编译本机 C 扩展(一些 gem 已包含)。

于 2013-03-10T18:03:01.660 回答