2

来自 Rails 和 Bundler 新手。

我能够在 MS Windows 7 上安装 rmagick 2.13.2:

gem install rmagick -v 2.13.2 -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include --local

哪个有效,显示在此输出中:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed rmagick-2.13.2
1 gem installed
Installing ri documentation for rmagick-2.13.2...
Installing RDoc documentation for rmagick-2.13.2...

但我无法让 bundler 使用我的 gemfile,其中包含以下行:

gem "rmagick"

但是命令:

bundle install --path vendor/bundle/

rmagick 上的错误如下:

Installing rmagick (2.13.2)
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:/ew/j2ee/axxon.dash/vendor/bundle/ruby/1.9.
1/gems/rmagick-2.13.2 for inspection.
Results logged to c:/ew/j2ee/axxon.dash/vendor/bundle/ruby/1.9.1/gems/rmagick-2.
13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

还,

>gem list rmagick

*** LOCAL GEMS ***

rmagick (2.13.2)

我检查并 rmagic 似乎安装在 vendor\bundle\ruby\1.9.1\gems\rmagick-2.13.2

因此,如果已安装,为什么 bundle install 会抱怨?我可以欺骗 bundler 并强迫它承认我做了什么吗?

TIA。

4

1 回答 1

4

你应该像这样定义 rmagick gem:

gem 'rmagick', '~> 2.13.2', :platforms => :ruby
gem 'rmagick', '=2.13.2.mswin32', :platforms => :mswin

希望这会有所帮助。

于 2013-07-17T15:06:29.453 回答