Rubygems requiring issue?
March, 27 2008 02:23 PM
I filed a ticket awhile ago to the rubygems project regarding what I consider a bug to the way it lets you require files. Here is what my ticket said:
======
When two different projects have a file with the same name inside of it, and you try to use require, you can get some
funky results. I'm not sure there is a solution for this, but it can get pretty frustrating when you realize it's requiring
the wrong file. Example:
I have two gems, anvil and rails. Anvil defines an initializer.rb inside of lib. Rails defines an initializer.rb inside
of lib. Now if I run require 'initializer', it picks anvil first because it is higher in the alphabet. The same I believe
applies to the gem command, but I haven't thoroughly tested that. Here were the results of my irb prompt prior
to uninstalling anvil (now I'm going to have to refactor anvil not to have an initializer.rb):
Macintosh-5:rails-2.0.2 lance$ irb
>> require 'rubygems'
=> false
>> require 'initializer'
=> true
>> Rails
NameError: uninitialized constant Rails
from (irb):3
After uninstalling anvil:
Macintosh-5:lancelot lance$ irb
>> require 'rubygems'
=> false
>> require 'initializer'
=> true
>> Rails
Thoughts?
======
Today I got a response saying that this was not a rubygems bug and that Anvil and Rails should duke it out? IMO, this not the expected behavior I had for requiring files, am I the only one in the same boat? I know I haven't submitted a patch for this, but at least keep this ticket open so I can file a patch eventually or maybe comment on the ticket encouraging me or someone else to write a patch for this!
Anyone else think this should be fixed?
Here is the ticket:
http://rubyforge.org/tracker/?func=detail&atid=575&aid=18890&group_id=126
About Lancelot Carlson and this blog
I created this blog from scratch using rails at a lightning quick pace. I figure, why not walk the walk
and use my blog as a testing bed for all those ruby/rails ideologies I evangelize. Here you will find
not only a digest of my learnings and brain dumps about topics ranging from Ruby to Nginx to Search Engine
Optimization, but also a laboratory. This is a place where the mad programmer in me can test my crazy ideas and
code in the wild and hopefully get enough interest to warrant some feedback.
Feel free to check out my working with rails profile for more information on me here.