我在windows上,我从这里(http://rubyforge.org/frs/?group_id=12&release_id=42049)下载并安装了rmagick-win32Rmagick-2.12.0-ImageMagick-6.5.6-8-q8,我用'gem install rmagick‘解压并安装了它。
当我尝试运行rails s时,我收到以下错误消息
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所以我尝试捆绑安装或捆绑更新,然后我得到了这个(为了节省空间,我去掉了完整的gem列表):
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.然后我下载了rmagick 2.13.2并将其放入相同的文件夹中,然后运行"gem install rmagick -v '2.13.2‘但我得到一个失败的错误:无法再次构建gem本地扩展
我正在尝试安装2.13.2,但是我找不到任何关于这个的信息。有人知道这是否是问题所在,以及如何解决?
发布于 2013-03-12 14:23:54
在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。
我已经创建了a batch file,它将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之后,您现在应该能够在Gemfile中仅与gem 'rmagick', :require => 'RMagick'捆绑。
发布于 2013-03-11 02:03:02
在Windows上,你需要Ruby的DevKit来编译原生的C扩展(一些gem已经包含了)。
https://stackoverflow.com/questions/15317341
复制相似问题