[Rubygems-developers] Another plug for Simon's patch
batsman.geo at yahoo.com
Wed Mar 31 15:06:29 EST 2004
On Tue, Mar 30, 2004 at 11:08:55PM -0700, Jamis Buck wrote:
> I currently have to do the following hack:
> require 'rubygems'
> require_gem 'log4r'
> rescue Exception
> require 'log4r'
As you said, this happens because your lib is available as a gem and a
non-gem. Two possible solutions would be
* dumping the non-gem version
* having the gem version as a separate branch and using a sensible
configuration management system
> With Simon's patch, I simply "require 'log4r'" and leave the rest up to
> the internals.
IMHO Simon's patch is dangerous (sorry Simon ;) for the following
* installation and loading of gems are separate in rubygems
* you can have more than one version of a lib installed
* require_gem (and require) defaults to the latest installed version
That is, IMHO require_gem 'log4r' is evil because it doesn't isolate
the lib from future changes in the API of log4r. Note that having the
right version installed is not enough, you have moreover to be careful
*not to install* a later, incompatible version; this can be tricky since
the new version could be required by some other gem.
If rubygems doesn't guarantee that the right one will be used, in
practice you cannot install several versions of a library, unless they
are compatible (in which case there's little merit in keeping an older
require_gem 'log4r', ">1.0.5" # implicit < 2.0 and assumes a versioning
require 'log4r' is certainly shorter and seductive, but unsafe.
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Software is like sex; it's better when it's free.
-- Linus Torvalds
More information about the Rubygems-developers