[Rubygems-developers] Tracking RubyGems as a dependency

Eric Hodel drbrain at segment7.net
Wed Jul 7 17:27:01 EDT 2010

On Jul 7, 2010, at 11:11, James Tucker wrote:
> On 7 Jul 2010, at 17:17, Jeremy Hinegardner wrote:
>> On Wed, Jul 07, 2010 at 04:36:43PM +0100, James Tucker wrote:
>>> Hi again,
>>> One of the things that has come up along the lines of research for better
>>> integration with system package managers is the idea of tracking rubygems
>>> itself as a dependency for gem code. Some package managers simply strip out
>>> "require 'rubygems'" from 3rd party code, which in most cases is workable
>>> given their installation plan, however, some libraries may use the Gem API,
>>> for example Gem.gunzip or the like (for want of a better example). I recognise
>>> it's hard to get 3rd party users to fill in gemspecs fully, and I have other
>>> ideas for that, but in light of simply allowing dependency lists to be filled
>>> in correctly, should there be a method to do this in the gemspec?
>>> At present specs contain a rubygems_version field that I'm not sure we even
>>> use. Can we add some kind of "uses_rubygems" boolean field for this purpose,
>>> as it seems depending on rubygems-update would be quite incorrect.

This is supposed to be the version of rubygems used to package the gem.  (RubyGems may need some defensive coding around this to prevent it from being overridden by people who set it in their gemspecs.)

>> I do believe this is the purpose of the :required_rubygems_version field
>> in the gemspec.
>> ##
>> # :attr_accessor: required_rubygems_version
>> #
>> # The RubyGems version required by this gem
>> attribute :required_rubygems_version, Gem::Requirement.default
> That claims therefore that *every* gem requires rubygems, which the folks I'm talking about will tell you isn't true. I'm trying to help them automate their tools by way of using spec fields that are valid. If this field was defaulted to nil, then explicitly set, then it would be valid.

Rake doesn't set this, so it defaults to ">= 0" (`gem spec -r rake required_rubygems_version`).

Perhaps we can bump specification_version and define a new behavior for required_rubygems_version using a newer spec_version:

> If required_rubygems_version is not set then RubyGems features are not used in the gem.  You must set required_rubygems_version in your gem if you wish to use RubyGems features in your gem.

We can continue defaulting to ">= 0" for backwards compatibility with older versions of RubyGems if necessary.  (I'm not sure what will happen if we use nil)

More information about the Rubygems-developers mailing list