2013-03-09 46 views
0

我在Windows上,並從此處下載並安裝了rmagick-win32 RMagick-2.12.0-ImageMagick-6.5.6-8-Q8(http://rubyforge.org/frs/?group_id=12&release_id=42049),我將其解壓縮並採用「創業板安裝rmagick」嘗試安裝Rmagick後無法運行rails server

當我嘗試運行軌道,按裝,我得到這個錯誤信息

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 

所以我嘗試捆綁安裝或捆綁更新,然後我得到這個(我拿出完整的寶石清單以節省空間):

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,放入同一個文件夾並運行「寶石安裝rmagick -v‘2.13.2’,但我得到一個失敗的錯誤:無法建立寶石原生擴展再次

我我試圖安裝2.13.2,但是我找不到任何有關這方面的信息。任何人都知道如果這是問題,以及如何解決這個問題?

回答

0

在Windows上,您需要使用Ruby的DevKit來編譯本機C擴展(包括一些gem)。

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 

然後,使用解壓寶石vendors/gems/

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

更好的解決方案

我發現,它有可能在Windows上編譯RMagick寶石。遵循此解決方案之前,請確保您已安裝DevKit

我創建a batch file說的ImageMagick的目錄映射爲X:\,並給出參數,在哪裏可以找到所需的文件來構建RMagick的gem命令。這種映射是必要的,因爲配置選項不知道如何處理路徑中的空格。

您可以使用以下命令將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'捆綁在一起。