Just providing closure on this.  I got no response, here or on the
jruby list, so I monkey-patched rubygems to do an exact name match for
'gem list'.  That fixed my problem, since all I care about is making
it work when called programmatically from my app.

I still think it's kind of an issue if "gem list activerecord
--remote" throws an exception, but oh well :)

-- Chad W.

On 4/30/07, Chad Woolley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I think this is actually a somewhat serious problem - anyone who tries
> to do a remote gem list on 'activerecord' with RubGems 0.9.2+ will get
> an exception.
>
> I've got a thread going on the Jruby and jruby-extra lists to have
> them look into it, but I'd like to fix the related problem in
> RubyGems.  Even if Jruby fixes this particular gem, it could still
> theoretically happen with another gem in the future - my upcoming
> rails-but-even-l337er gem, for example.  (that was a joke)
>
> The real problem that I see is the wildcard matching of the remote gem
> list command, which cannot currently be overridden.  If it could, then
> I could just request an exact match like /^activerecord$/, and not
> even pick up the ActiveRecord-jdbc gem.
>
> So, I could hack this in by making a change to the
> Gem::Commands::ListCommand#execute method, and trying to make it
> "detect" whether some regexp was passed as the argument.  It currently
> matches /^#{string}/, which is the wildcard matching at the root of
> the problem.
>
> However, fixing this proved to be tricky to do without breaking any of
> the existing behavior.  Should the gem list search term be the
> forward-slash-delimited regexp style?  If so, how to detect that?
> Eval'ing and checking the type could cause a syntax error if the eval
> rails.  Passing it to Regexp.compile to see if it compiles would
> require stripping the slash delimiters (and any other trailing flags).
>
> There could also be a separate command-line flag to the 'gem list'
> command to specify and exact name match instead of a wildcard -
> perhaps '--exact-match'?
>
> Alternately, we could fix whatever it was that allowed this invalid
> gem to be uploaded and indexed on the rubygems mirrors, but I have no
> idea where to start on that one.  I looked at the ActiveRecord-JDBC
> gem source, and I see nothing suspicious - it's just a standard Hoe
> config.  Not even any mention of YAML::Private anywhere.
>
> So, to summarize, I'd be glad to help fix this, but I'd appreciate
> some direction from the devs so I don't waste time going down the
> wrong path.
>
> Thanks,
> Chad
>
> On 4/28/07, Chad Woolley <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I get the following error when listing ActiveRecord-JDBC remotely with
> > RubyGems 0.9.2.  It happens on OSX and Linux, but not windows.  It
> > doesn't happen on RubyGems 0.9.0.  There also looks like there's a
> > related bug which is open:
> >
> > http://rubyforge.org/tracker/index.php?func=detail&aid=8359&group_id=126&atid=575
> >
> > Here's the error.  It also occurs when using plain 'activerecord' as
> > the search string, but I think this is because ActiveRecord-JDBC is
> > matching the substring, because you can see that activerecord-mimer
> > does not get an error:
> >
> > /> gem --version
> > 0.9.2
> > /> gem list ActiveRecord-JDBC --remote --debug --backtrace
> > Exception `Errno::ENOENT' at
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:51 - No such
> > file or directory - /Users/pivotal/.gemrc
> >
> > *** REMOTE GEMS ***
> > Exception `NoMethodError' at
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:136 - private
> > method `scan' called for #<YAML::PrivateType:0x4afc610>
> > ERROR:  While executing gem ... (NoMethodError)
> >     private method `scan' called for #<YAML::PrivateType:0x4afc610>
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:136:in `to_ints'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:147:in `<=>'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:198
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:292:in `satisfy?'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:283:in `satisfied_by?'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `all?'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/version.rb:283:in `satisfied_by?'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:210:in `search'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:208:in `search'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_info_cache.rb:109:in 
> > `search'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `map'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_info_cache.rb:108:in 
> > `search'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_info_cache.rb:49:in 
> > `search'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:806:in `execute'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:886:in `execute'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/command.rb:70:in `invoke'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:120:in 
> > `process_args'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:91:in `run'
> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:30:in `run'
> > /usr/local/bin/gem:23
> > /> gem list activerecord-mimer --remote
> >
> > *** REMOTE GEMS ***
> >
> >
> > activerecord-mimer (0.0.4, 0.0.3, 0.0.2, 0.0.1)
> >     Mimer support for ActiveRecord.
> > />
> >
>
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers

Reply via email to