开发者

RMagick Gem will not load in Ruby script

I installed RMagick on my MacOSX system and when I try it with IRB everything works fine:

~ $ irb -rubygems -r RMagick
irb(main):001:0> p Magick::Long_version
"This is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) ..."
=> nil

But when I try to put this in a simple Ruby script:

#!/opt/local/bin/ruby
require "rubygems"
require "RMagick"

puts Magick::Long_version

it will fail:

$ ./rmagick.rb
./RMagick.rb:5: uninitialized constant Magick (NameError)
from /opt/local/l开发者_如何学Pythonib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./rmagick.rb:3

Any suggestions on this problem?


Rename your file to something other than rmagick.rb it confuses you ruby interpreter, when you say require "rmagick".

It will work after you rename it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜