[Rubygems-developers] Overhaul of specification.rb

Gavin Sinclair gsinclair at soyabean.com.au
Thu Aug 5 11:13:43 EDT 2004

On Thursday, August 5, 2004, 8:23:16 AM, Chad wrote:

> On Aug 1, 2004, at 10:56 AM, Gavin Sinclair wrote:

>> Guys,
>> I've done a lot of work on specification.rb.  The motivation was to
>> organise the code a bit better, and give special treatment to all
>> gemspec attributes to prevent repitition.  I wanted to add
>> 'library_stubs' and 'test_files' attributes, and deprecate
>> 'test_suite_file', but also to ensure that the overall code was
>> written and tested well.

> Looks like this introduced a major bug, probably having to do with the
> way default values for optional dependencies are generated/handled:

> chadfowler$ sudo ruby -I lib bin/gem install rake
> Attempting local installation of 'rake'
> Local gem file not found: rake.gem
> Attempting remote installation of 'rake'
> ERROR:  While executing gem ... (NoMethodError)
>      undefined method `each' for nil:NilClass

I took a look today but didn't have very long.  It's to do with the
way the gem spec is created.  If it's deserialized from YAML, then it
doesn't go through the #initialize process, which is the problem.
Before my change, empty/nil properties were not written to YAML, so
when they're loaded in, they're still empty/nil.  The old spec code
was OK with this because some of the accessors were like this:

  def dependencies
    @dependencies ||= []

The code now writes a complete YAML spec and has plain accessors.
There are clearly issues with both of those behaviours.  Probably the
best option is to generate the accessors like above.  Whether the
entire YAML is written out or not is a matter of taste.
Aesthetically, I'd prefer not to.  To avoid inter-spec-version
problems (like this one :) I'd rather do so.  It's something that
requires a bit of thought, methinks.

Anyway, I'll change the code (tomorrow) to generate smart accessors,
and I'm 99% sure that will fix the problem.  Thanks for pointing it

BTW, you can use "rake gem ..." to run the local (non-installed) gem
code, IIRC.  And it doesn't matter what (sub)directory you're in.  Did
I ever mention I love Rake?


More information about the Rubygems-developers mailing list