tags:

views:

9

answers:

1

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/lib/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?

+2  A: 

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.

Rishav Rastogi
Arggghh. Thanks, man. Such a silly error.
AlphaOne