Frustrating "require" problems with RMagick

Adam Block wrote:

[OS X]

require 'RMagick'

[DELETED: Many error of the type:
/usr/local/lib/ruby/site_ruby/1.8/RMagick.rb:32: warning: already
initialized constant PercentGeometry]

Try deleting the non-gem site_ruby installation of RMagick on OSX.

And then use:

   require_gem 'rmagick'
   require 'RMagick'

Adam Block wrote:

My best guess is that there is actually something wrong with the gem build on FC5. I've tried every combination of recompilation so I'm sort of stuck. ImageMagick command line apps work fine and as far as I can tell all the libraries are there and the library paths are set in /etc/

The gem build works fine for me on FC6, but I do need to use
the double-barreled require

    require_gem 'rmagick'
    require 'RMagick'

which is not what the docs say you need to do.

Perhaps update to the latest ImageMagick and ImageMagick-devel
packages, or build ImageMagick from source.

The trick is that HFS+ filesystem of Mac OS X is case-insensitive by
default. So "RMagick" and "rmagick" is the same on osx. But it's not
the case in other case-sensitive filesystems.

I had the completely the same issue deploying my RoR app to Debian. So
be careful with names in require.


Or the simple way that require tracks the already-loaded files makes the names 'rmagick' and 'RMagick' different (since Ruby Strings are case-sensitive regardless of the file system). See the footnote on p.124 of the pickaxe (Programming Ruby, 2nd ed.) for more including the bit "Some consider this a bug, and this behavior may well change in later releases."


Rob Biedenharn


-- Ezra Zygmuntowicz-- Lead Rails Evangelist
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)