 |
Forums |
Admin Start New Thread
| Message: 16762 |
 |
BY: Tim Hunter (rmagick) DATE: 2007-01-06 19:13 SUBJECT: Two Myths About the RMagick Gem From time to time I see blog entries or postings on various mailing lists that contain misinformation about using the RMagick gem. Here's two common myths that I see, along with the correct information.
Myth 1: To use the RMagick gem, you should use this statement in your script:
require_gem "rmagick"
Truth: The require_gem method is not and never has been intended to be a replacement for the standard require method. It's purpose has always been to identify a specific version of a gem to be loaded. In earlier releases of RubyGems it was possible to make require_gem indirectly require the gem, which led to the belief that require_gem should or could be used instead of require.
You should always use require to load RMagick, even when you installed RMagick as a gem.
(The require_gem method is deprecated in the newest release of RubyGems. If you need to use a specific version of a gem, use the gem method instead.)
Myth 2: You should require "rmagick", not "RMagick".
Truth: The name of the gem is "rmagick". The name of the library is "RMagick" and that is the name you should use. On operating systems with case-insensitive filesystems, such as MS Windows and OS X, you can get by with requiring "rmagick", but that won't work on Linux because Linux filesystems (at least all the common ones) are case-sensitive. "RMagick" will always work no matter which operating system you use.
Another problem with using "rmagick", even on systems that permit it, is that Ruby is always case-sensitive even when the filesystem isn't. Ruby remembers which libraries have been required and won't require the same library twice. However, if your program (or some library used by your program) requires "rmagick" and then later your program (or some library) later requires "RMagick", Ruby thinks that the two are different files and tries to load RMagick again. This causes Ruby to issue many, many warning messasges as RMagick.rb redefines its constants and does other initialization things that should only be done once per exectuion | |
Thread View
Post a followup to this message
|
 |