[Rubygems-developers] gem() command caches gem list upon first invocation

John Trupiano jtrupiano at gmail.com
Fri Mar 6 01:17:18 EST 2009


Hey guys, see my message below regarding a caching issue with the gem()
function.  At this point, I just want to report the information I've
gathered regarding the specifics of the bug.  I am willing to troubleshoot
this further, but to be honest, I'm not sure how to go about modifying the
rubygems library itself.  Are there instructions for how to maintain your
own fork/branch of the library so that I can continue to troubleshoot the
issue?

-John\

---------- Forwarded message ----------
From: John Trupiano <jtrupiano at gmail.com>
Date: Thu, Mar 5, 2009 at 8:06 PM
Subject: Re: GemInstaller --- #install then #autogem
To: Chad Woolley <thewoolleyman at gmail.com>


Hey Chad, it looks to me like it's a problem in the rubygems API.  The
Gem::SourceIndex class properly picks up on the newly installed gem, but the
call to gem() does not.  But, there's a wrinkle.  This only happens if a
call to gem for that gem previously failed.

*Scenario 1: Install gem before trying to activate it, then activate it with
success
*john-mbp:trunk john$ irb
>> Gem::SourceIndex.from_installed_gems.search("jtrupiano-sanitize_email")
:0:Warning: Gem::SourceIndex#search support for String patterns is
deprecated
=> []
>> `sudo gem install jtrupiano-sanitize_email`
=> "Successfully installed jtrupiano-sanitize_email-0.1.0\n1 gem
installed\nInstalling ri documentation for
jtrupiano-sanitize_email-0.1.0...\nInstalling RDoc documentation for
jtrupiano-sanitize_email-0.1.0...\n"
>> Gem::SourceIndex.from_installed_gems.search("jtrupiano-sanitize_email")
:0:Warning: Gem::SourceIndex#search support for String patterns is
deprecated
=> [#<Gem::Specification:0x112374c ........>]
>> gem 'jtrupiano-sanitize_email', '= 0.1.0'
=> true

*Scenario 2: Try to activate the gem before it's installed, then install it,
then try to activate again, and fail.
*john-mbp:trunk john$ sudo gem uninstall jtrupiano-sanitize_email
Successfully uninstalled jtrupiano-sanitize_email-0.1.0
john-mbp:trunk john$ irb
>> Gem::SourceIndex.from_installed_gems.search("jtrupiano-sanitize_email")
:0:Warning: Gem::SourceIndex#search support for String patterns is
deprecated
=> []
>> gem 'jtrupiano-sanitize_email', '= 0.1.0'
Gem::LoadError: Could not find RubyGem jtrupiano-sanitize_email (= 0.1.0)

    from /Library/Ruby/Site/1.8/rubygems.rb:636:in `report_activate_error'
    from /Library/Ruby/Site/1.8/rubygems.rb:141:in `activate'
    from /Library/Ruby/Site/1.8/rubygems.rb:49:in `gem'
    from (irb):2
>> `sudo gem install jtrupiano-sanitize_email`
=> "Successfully installed jtrupiano-sanitize_email-0.1.0\n1 gem
installed\nInstalling ri documentation for
jtrupiano-sanitize_email-0.1.0...\nInstalling RDoc documentation for
jtrupiano-sanitize_email-0.1.0...\n"
>> Gem::SourceIndex.from_installed_gems.search("jtrupiano-sanitize_email")
:0:Warning: Gem::SourceIndex#search support for String patterns is
deprecated
=> [#<Gem::Specification:0x183d62c ....>]
>> gem 'jtrupiano-sanitize_email', '= 0.1.0'
Gem::LoadError: Could not find RubyGem jtrupiano-sanitize_email (= 0.1.0)

    from /Library/Ruby/Site/1.8/rubygems.rb:636:in `report_activate_error'
    from /Library/Ruby/Site/1.8/rubygems.rb:141:in `activate'
    from /Library/Ruby/Site/1.8/rubygems.rb:49:in `gem'
    from (irb):5



So the caching issue appears to be further up the stack, specifically in the
rubygems library itself.  I'm done looking into this for the evening, but
wanted to pass along my findings in the interim.  I'm going to continue
working on this over the weekend.

-John


On Tue, Mar 3, 2009 at 11:08 AM, Chad Woolley <thewoolleyman at gmail.com>wrote:

> That would be great.  I've only ever looked at this briefly.
> - Show quoted text -
> - Show quoted text -
>
> On Tue, Mar 3, 2009 at 7:07 AM, John Trupiano <jtrupiano at gmail.com> wrote:
> > Hey Chad, thanks for the response.  I was poking a bit around the
> > geminstaller code before I reached out to you.  I do think that I can
> give
> > you a hand on this one.  Schedule's a little tight today/tomorrow, but I
> > have gobs of time available this weekend.  I'll follow up.
> >
> > -John
> >
> > On Mon, Mar 2, 2009 at 9:44 PM, Chad Woolley <thewoolleyman at gmail.com>
> > wrote:
> >>
> >> Yep, that has been a bug forever:
> >>
> >>
> >>
> http://thewoolleyweb.lighthouseapp.com/projects/11580/tickets/3-autogem-fails-when-run-for-newly-installed-gem
> >>
> >> I think it is a problem with rubygems caching, but I've never looked
> >> into it.  It bites us all the time.  You're welcome to take a look :)
> >> I'm trying to make a priority to fix all these and get GemInstaller to
> >> 1.0 release - especially since more and more people become convinced
> >> config.gems is broken.
> >>
> >> -- Chad
> >> - Show quoted text -
> >> On Mon, Mar 2, 2009 at 3:11 PM, John Trupiano <jtrupiano at gmail.com>
> wrote:
> >> > Hey Chad,
> >> >
> >> > It appears that I cannot run an install immediately followed by an
> >> > autogem:
> >> >
> >> > john-mbp:trunk john$ irb
> >> >>> gem 'geminstaller', '=0.5.1'
> >> > => true
> >> >>> require 'geminstaller'
> >> > => true
> >> >>> GemInstaller.install('--sudo --config=config/geminstaller.yml')
> >> > Invoking gem install for jtrupiano-sanitize_email, version 0.1.0.
> >> > => 0
> >> >>> require 'sanitize_email'
> >> > LoadError: no such file to load -- sanitize_email
> >> >     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
> >> > `gem_original_require'
> >> >     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
> >> > `require'
> >> >     from (irb):4
> >> >>> GemInstaller.autogem('--config=config/geminstaller.yml')
> >> > Error: GemInstaller attempted to load gem 'jtrupiano-sanitize_email',
> >> > version '= 0.1.0', but that version is not installed.  Use
> GemInstaller
> >> > to
> >> > install the gem.  Original Gem::LoadError was: 'Could not find RubyGem
> >> > jtrupiano-sanitize_email (= 0.1.0)'
> >> > => 1
> >> >
> >> > What you'll see is that I can install the gem just fine, but I cannot
> >> > subsequently activate/load it.  If I exit and reload irb, it will
> >> > activate
> >> > the newly-installed gem just fine.
> >> >
> >> > I'm trying to set it up so that the gems auto-install in my automated
> >> > and
> >> > development environments.  What technique do you use to accomplish
> this?
> >> > This seems to be following the same convention you used in the sample
> >> > (geminstaller_rails_preinitializer.rb).  Do you notice anything that
> I'm
> >> > doing incorrectly here?
> >> >
> >> > Thanks, and no worries if you're unable to help.
> >> >
> >> > -John
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rubygems-developers/attachments/20090306/847da49f/attachment.html>


More information about the Rubygems-developers mailing list