2012-04-25 172 views
2

當我在軌運行在我的lib文件夾命令紅寶石billede.rb我得到的錯誤:Rmagick:'需要':沒有這樣的文件來加載 - RMagick(LoadError)

C:\Rails\myapp\lib>ruby billede.rb 
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 
no such file to load -- RMagick (LoadError) 
     from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i 
n `require' 
     from billede.rb:2:in `<main>' 

我Billede .rb:

class Billede 
require 'rubygems' 
require 'RMagick' 

if !ARGV[0] 
    puts "Usage: watermark /image.png" 
    exit 
end 

image = Magick::Image.read(ARGV[0]).first 

mark = Magick::Image.new(image.columns, image.rows) 

gc = Magick::Draw.new 
gc.gravity = Magick::CenterGravity 
gc.pointsize = 32 
gc.font_family = "Helvetica" 
gc.font_weight = Magick::BoldWeight 
gc.stroke = 'none' 
gc.annotate(mark, 0, 0, 0, 0, "Watermark\nby\nRMagick") 

mark = mark.shade(true, 310, 30) 

image.composite!(mark, Magick::CenterGravity, Magick::HardLightCompositeOp) 

out = ARGV[0].sub(/\./, "-wm.") 
puts "Writing #{out}" 
image.write(out) 
end 

我已經安裝了RMagick。

安裝寶石時進行更新。

在我的Gemfile我:

gem "rmagick", :require => 'RMagick' 

當運行捆綁安裝:

C:\Rails\myapp>bundle install 
Fetching source index for http://rubygems.org/ 
Using rake (0.9.1) 
Using abstract (1.0.0) 
Using activesupport (3.0.9) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.9) 
Using erubis (2.6.6) 
Using rack (1.2.4) 
Using rack-mount (0.6.14) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.30) 
Using actionpack (3.0.9) 
Using mime-types (1.16) 
Using polyglot (0.3.2) 
Using treetop (1.4.10) 
Using mail (2.2.19) 
Using actionmailer (3.0.9) 
Using arel (2.0.10) 
Using activerecord (3.0.9) 
Using activeresource (3.0.9) 
Using addressable (2.2.6) 
Using bundler (1.0.18) 
Using multipart-post (1.1.4) 
Using faraday (0.7.6) 
Using friendly_id (4.0.0) 
Using hashie (1.2.0) 
Using json (1.6.1) 
Using multi_json (1.0.4) 
Using mysql (2.8.1) 
Using oauth2 (0.5.2) 
Using omniauth (1.0.2) 
Using omniauth-oauth2 (1.0.0) 
Using omniauth-facebook (1.2.0) 
Using rdoc (3.10) 
Using thor (0.14.6) 
Using railties (3.0.9) 
Using rails (3.0.9) 
Using rest-client (1.6.7) 
Installing rmagick (2.13.1) with native extensions C:/Ruby192/lib/ruby/site_ruby 
/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR 
: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     C:/Ruby192/bin/ruby.exe extconf.rb 
checking for Ruby version >= 1.8.5... yes 
checking for stdint.h... yes 
checking for sys/types.h... yes 
checking for wand/MagickWand.h... yes 
checking for snprintf() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdin 
t.h,sys/types.h,wand/MagickWand.h... yes 
checking for AcquireImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,s 
tdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for AffinityImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h, 
stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for AffinityImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h 
,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for AutoGammaImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h 
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for AutoLevelImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h 
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for BlueShiftImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h 
,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for ConstituteComponentTerminus() in assert.h,ctype.h,stdio.h,stdlib.h, 
math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for DeskewImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,st 
dint.h,sys/types.h,wand/MagickWand.h... yes 
checking for EncipherImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h, 
stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for EqualizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for FloodfillPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t 
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for FunctionImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for GetAuthenticIndexQueue() in assert.h,ctype.h,stdio.h,stdlib.h,math. 
h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for GetAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,ti 
me.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for GetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for GetVirtualPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time 
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for LevelImageColors() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time 
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for LevelColorsImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math 
.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for LevelizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for LiquidRescaleImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,ti 
me.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for MagickLibAddendum() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,tim 
e.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for OpaquePaintImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math 
.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for QueueAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for RemapImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,std 
int.h,sys/types.h,wand/MagickWand.h... yes 
checking for RemoveImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t 
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SelectiveBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,ma 
th.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h, 
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SetImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time 
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SetMagickMemoryMethods() in assert.h,ctype.h,stdio.h,stdlib.h,math. 
h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SparseColorImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time 
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for SyncAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t 
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for TransparentPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h 
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for TransparentPaintImageChroma() in assert.h,ctype.h,stdio.h,stdlib.h, 
math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for QueryMagickColorname() new signature... yes 
checking for Image.type in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdin 
t.h,sys/types.h,wand/MagickWand.h... yes 
checking for DrawInfo.kerning in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h 
,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for DrawInfo.interline_spacing in assert.h,ctype.h,stdio.h,stdlib.h,mat 
h.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for DrawInfo.interword_spacing in assert.h,ctype.h,stdio.h,stdlib.h,mat 
h.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for DitherMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,std 
int.h,sys/types.h,wand/MagickWand.h... yes 
checking for MagickFunction in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,s 
tdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for ImageLayerMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h 
,stdint.h,sys/types.h,wand/MagickWand.h... yes 
checking for long double in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdi 
nt.h,sys/types.h,wand/MagickWand.h... yes 
checking for AlphaChannelType.CopyAlphaChannel... yes 
checking for AlphaChannelType.BackgroundAlphaChannel... yes 
checking for CompositeOperator.BlurCompositeOp... yes 
checking for CompositeOperator.DistortCompositeOp... yes 
checking for CompositeOperator.LinearBurnCompositeOp... yes 
checking for CompositeOperator.LinearDodgeCompositeOp... yes 
checking for CompositeOperator.MathematicsCompositeOp... yes 
checking for CompositeOperator.PegtopLightCompositeOp... yes 
checking for CompositeOperator.PinLightCompositeOp... yes 
checking for CompositeOperator.VividLightCompositeOp... yes 
checking for CompressionType.DXT1Compression... yes 
checking for CompressionType.DXT3Compression... yes 
checking for CompressionType.DXT5Compression... yes 
checking for CompressionType.ZipSCompression... yes 
checking for CompressionType.PizCompression... yes 
checking for CompressionType.Pxr24Compression... yes 
checking for CompressionType.B44Compression... yes 
checking for CompressionType.B44ACompression... yes 
checking for DistortImageMethod.BarrelDistortion... yes 
checking for DistortImageMethod.BarrelInverseDistortion... yes 
checking for DistortImageMethod.BilinearForwardDistortion... yes 
checking for DistortImageMethod.BilinearReverseDistortion... yes 
checking for DistortImageMethod.DePolarDistortion... yes 
checking for DistortImageMethod.PolarDistortion... yes 
checking for DistortImageMethod.PolynomialDistortion... yes 
checking for DistortImageMethod.ShepardsDistortion... yes 
checking for DitherMethod.NoDitherMethod... yes 
checking for FilterTypes.KaiserFilter... yes 
checking for FilterTypes.WelshFilter... yes 
checking for FilterTypes.ParzenFilter... yes 
checking for FilterTypes.LagrangeFilter... yes 
checking for FilterTypes.BohmanFilter... yes 
checking for FilterTypes.BartlettFilter... yes 
checking for FilterTypes.SentinelFilter... yes 
checking for MagickEvaluateOperator.PowEvaluateOperator... yes 
checking for MagickEvaluateOperator.LogEvaluateOperator... yes 
checking for MagickEvaluateOperator.ThresholdEvaluateOperator... yes 
checking for MagickEvaluateOperator.ThresholdBlackEvaluateOperator... yes 
checking for MagickEvaluateOperator.ThresholdWhiteEvaluateOperator... yes 
checking for MagickEvaluateOperator.GaussianNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.ImpulseNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.LaplacianNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.MultiplicativeNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.PoissonNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.UniformNoiseEvaluateOperator... yes 
checking for MagickEvaluateOperator.CosineEvaluateOperator... yes 
checking for MagickEvaluateOperator.SineEvaluateOperator... yes 
checking for MagickEvaluateOperator.AddModulusEvaluateOperator... yes 
checking for MagickFunction.ArcsinFunction... yes 
checking for MagickFunction.ArctanFunction... yes 
checking for MagickFunction.PolynomialFunction... yes 
checking for MagickFunction.SinusoidFunction... yes 
checking for ImageLayerMethod.FlattenLayer... yes 
checking for ImageLayerMethod.MergeLayer... yes 
checking for ImageLayerMethod.MosaicLayer... yes 
checking for ImageLayerMethod.TrimBoundsLayer... yes 
checking for VirtualPixelMethod.HorizontalTileVirtualPixelMethod... yes 
checking for VirtualPixelMethod.VerticalTileVirtualPixelMethod... yes 
checking for VirtualPixelMethod.HorizontalTileEdgeVirtualPixelMethod... yes 
checking for VirtualPixelMethod.VerticalTileEdgeVirtualPixelMethod... yes 
checking for VirtualPixelMethod.CheckerTileVirtualPixelMethod... yes 
checking for ruby/io.h... yes 
checking for rb_frame_this_func() in ruby.h,ruby/io.h... yes 
creating extconf.h 
creating Makefile 


====================================================================== 
Wed 25Apr12 14:10:35 
This installation of RMagick 2.13.1 is configured for 
Ruby 1.9.2 (i386-mingw32) and ImageMagick 6.7.6 
====================================================================== 



make 


Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2 
.13.1 for inspection. 
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick 
/gem_make.out 
     from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `b 
lock in build_extensions' 
     from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `e 
ach' 
     from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `b 
uild_extensions' 
     from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `i 
nstall' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour 
ce.rb:101:in `block in install' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby 
gems_integration.rb:78:in `preserve_paths' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour 
ce.rb:91:in `install' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst 
aller.rb:58:in `block (2 levels) in run' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby 
gems_integration.rb:93:in `with_build_args' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst 
aller.rb:57:in `block in run' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst 
aller.rb:49:in `run' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst 
aller.rb:8:in `install' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/cli. 
rb:220:in `install' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend 
or/thor/task.rb:22:in `run' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend 
or/thor/invocation.rb:118:in `invoke_task' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend 
or/thor.rb:263:in `dispatch' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend 
or/thor/base.rb:386:in `start' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/bin/bundle:13:in 
`<top (required)>' 
     from C:/Ruby192/bin/bundle:19:in `load' 
     from C:/Ruby192/bin/bundle:19:in `<main>' 

C:\Rails\myapp> 
+0

你在一個Rails應用程序? – 2012-04-25 09:17:49

+0

RMagick安裝成功了嗎?有關安裝說明,請參閱[Windows說明](http://rmagick.rubyforge.org/install-faq.html#win)。 – Jamie 2012-04-25 09:49:05

+0

不應該RMagick小寫? (在你需要對線路,我的意思) – d11wtq 2012-04-25 10:18:09

回答

0

在Rails項目外部腳本應如下運行:

bundle exec lib/billede.rb <params> 

(使確定你在Gemfile中有gem 'RMagick'

在出現任何依賴性問題的情況下,您將獲得更多描述性輸出。

+0

我已經更新了我的進一步資料的問題'make'輸出。當我運行的命令,我得到:C:\ Rails的\ MYAPP>捆綁高管的lib/billede.rb 找不到寶石「rmagick(> = 0)」中的任何在你的寶石 文件中列出的寶石的來源。 – 2012-04-25 12:15:56

+0

它應該是'gem'RMagick'' – forker 2012-04-25 21:55:47

+0

C:\ Rails \ myapp>軟件包安裝 獲取http://rubygems.org/的源索引 找不到gem'RMagick(> = 0)'寶石來源列在您的Gem 文件中。 C:\ Rails \ myapp> – 2012-04-26 08:42:06

2

如果您使用的捆紮機(當您使用您使用Rails的捆紮機,太),你需要RMagick添加到您的Gemfile。 Bundler只會將捆綁的寶石加載到您的環境中。

的Gemfile

source :rubygems 

# loads of other stuff 

gem 'rmagick' 

然後運行

bundle install 

,你應該是好去

0

您需要首先安裝imagemagic:

sudo apt-get install libmagickwand-dev imagemagick 

然後添加紅寶石包裝您的Gemfile:

gem 'rmagick' 

最後告訴捆紮機下載rmagic:

bundle install 
相關問題