Forum: Ruby strange results when require'ing RMagick

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John Conrad (Guest)
on 2006-06-04 15:45
(Received via mailing list)
I've read about some packages that return false when they are require'd
through rubygem's special version of require, and I think I understand
the
issue well enough. But this behavior has me confused anew...

Included are the transcripts from two separate irb sessions where I
attempt
to require RMagick. Apparently the only way I can get the library loaded
is
by require'ing it twice but switching the case of the first two letters
between calls to require.

Thanks in advance for any help with this,
John Emerson Conrad

$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.5.0]

[FIRST SESSION]

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'RMagick'
=> false
irb(main):003:0> Magick
NameError: uninitialized constant Magick
        from (irb):3
        from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:227
irb(main):004:0> require 'rmagick'
=> true
irb(main):005:0> Magick
=> Magick
irb(main):006:0> exit

[SECOND SESSION]

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rmagick'
=> false
irb(main):003:0> require 'RMagick'
=> true
Timothy Hunter (Guest)
on 2006-06-04 16:34
(Received via mailing list)
John Conrad wrote:
> between calls to require.
> irb(main):001:0> require 'rubygems'
> irb(main):005:0> Magick
> irb(main):003:0> require 'RMagick'
> => true
>
What version of RMagick do you have installed?

In the 2nd session, when require returns "false", try this:

puts Magick::Long_version

What happens?
John Conrad (Guest)
on 2006-06-04 16:52
(Received via mailing list)
On 6/4/06, Timothy Hunter <TimHunter@nc.rr.com> wrote:
>
I have rmagick-1.11.1 installed, and I uninstalled all previous versions
to
make sure they weren't somehow confusing my system.

The second session is the same as the first session except the order of
the
calls are reversed. The constant 'Magick' is uninitialized until I make
the
second call to require (perhaps I should have demonstrated this
explicitly
as I did in the first session).

Anyway, here's what happens:

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rmagick'
=> false
irb(main):003:0> puts Magick::Long_version
NameError: uninitialized constant Magick
        from (irb):3
        from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:227
Timothy Hunter (Guest)
on 2006-06-04 20:52
(Received via mailing list)
John Conrad wrote:
>>
> explicitly
> NameError: uninitialized constant Magick
>        from (irb):3
>        from
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:227
>
I'm stumped. I purged my playpen version of RMagick and installed it via
a normal "gem install":

timothyhunter$ ruby --version
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0]
timothyhunter$ gem --version
0.8.11
timothyhunter$ irb
irb(main):001:0> Magick
NameError: uninitialized constant Magick
        from (irb):1
irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'RMagick'
=> true
irb(main):004:0> puts Magick::Long_version
This is RMagick 1.11.1 ($Date: 2006/05/27 21:05:59 $) Copyright (C) 2006
by Timothy P. Hunter
Built with ImageMagick 6.2.7 04/27/06 Q8 http://www.imagemagick.org
Built for ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0]
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=> nil
irb(main):005:0>
John Conrad (Guest)
on 2006-06-04 22:08
(Received via mailing list)
> I'm stumped. I purged my playpen version of RMagick and installed it via
> a normal "gem install":


After I have loaded RMagick (by require'ing it twice and changing from
'RMagick' to 'rmagick' between require calls), I get the same result as
you
from puts Magick::Long_version.

Man I'm stumped.

Thanks for trying...

JEC
Timothy Hunter (Guest)
on 2006-06-04 22:30
(Received via mailing list)
John Conrad wrote:
>
> Thanks for trying...
>
> JEC
>
One last thing: I'm using RubyGems 0.8.11.

As a last resort you could uninstall the rmagick gem and install RMagick
from source. It's not all that much more work (especially since you've
already got ImageMagick/GraphicsMagick installed) and then you just
wouldn't have to depend on RubyGems.
John Conrad (Guest)
on 2006-06-04 23:34
(Received via mailing list)
> One last thing: I'm using RubyGems 0.8.11.
>
> As a last resort you could uninstall the rmagick gem and install RMagick
> from source. It's not all that much more work (especially since you've
> already got ImageMagick/GraphicsMagick installed) and then you just
> wouldn't have to depend on RubyGems.
>
>
I'm using RubyGems 0.8.11 too. Sorry, I forgot to mention that before.
Thanks for your help. I think I'll follow your advice and install from
source.

(But if anybody else on the list has any clue what's going on, I'd still
love to solve this mystery.)

JEC
This topic is locked and can not be replied to.