[Rubygems-developers] The deprecation of autorequire

Austin Ziegler halostatue at gmail.com
Thu Jan 15 09:31:32 EST 2009

On Thu, Jan 15, 2009 at 12:17 AM, Chad Woolley <thewoolleyman at gmail.com> wrote:
> On Wed, Jan 14, 2009 at 10:08 PM, Jim Weirich <jim.weirich at gmail.com> wrote:
>> Only use a 'gem' command if you want something other than the latest
>> installed version of a gem.  You application should arrange to invoke the
>> gem command early in the program, after 'rubygems' has been required, but
>> before any other requires have run.
> We use GemInstaller's 'autogem' function to accomplish this via
> /config/preinitializer.rb in all our Rails apps:
> This works very well for us, and I believe Rails' config.gems can do
> the same thing (except for Rails itself, would cause the universe to
> implode)

Some of this might be helped if RubyGems provided a "default require"
piece of metadata that could be queried about a gem. One of the
complaints that I've heard—and don't really have a fix for—is that the
names of gems and what you require are different. When I was working
on PDF::Writer, for example, it was:

  gem 'pdf-writer', '=1.1.8'
  require 'pdf/writer'

Now, those two are close enough, but it wasn't "require 'pdf-writer'",
which is what some people apparently expect. (I'm not sure why; maybe
it was the early autorequire.)

If we had a way of querying a gem for it's "full require" or "default
require", it might help at least with exploration of a gem. One way
that we could do this is to make it so that the "gem" command returns
a read-only copy of the spec:

  pdf_writer = gem 'pdf-writer', '=1.1.8'
  require pdf_writer.default_require

Or something like that.

Austin Ziegler * halostatue at gmail.com * http://www.halostatue.ca/
               * austin at halostatue.ca * http://www.halostatue.ca/feed/
               * austin at zieglers.ca

More information about the Rubygems-developers mailing list