[Rubygems-developers] [ rubygems-Bugs-27712 ] RubyGems Plugins: odd behavior when gem w/ plugin has multiple installed versions.

noreply at rubyforge.org noreply at rubyforge.org
Thu Jan 21 04:39:05 EST 2010


Bugs item #27712, was opened at 2010-01-20 22:51
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=27712&group_id=126

Category: other
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 3
Submitted By: Nick Howard (baroquebobcat)
>Assigned to: Eric Hodel (drbrain)
Summary: RubyGems Plugins: odd behavior when gem w/ plugin has multiple installed versions.

Initial Comment:
When I run gem rdoc with multiple copies of yard installed, I get a SystemStackError because each version of yard installed's rubygems_plugin.rb file is loaded. I think that rubygems shouldn't load the rubygems_plugin.rb files for all installed versions of a gem, it should only load the latest version of the plugins.

$ sudo gem rdoc sinatra --backtrace
ERROR: While executing gem ... (SystemStackError)
    stack level too deep
/usr/lib/ruby/gems/1.8/gems/yard-0.5.2/lib/rubygems_plugin.rb:19:in `has_rdoc?'
/usr/lib/ruby/gems/1.8/gems/yard-0.4.0/lib/rubygems_plugin.rb:77:in `install_ri_yard_orig'
/usr/lib/ruby/gems/1.8/gems/yard-0.4.0/lib/rubygems_plugin.rb:77:in `install_ri_yard_orig'
/usr/lib/ruby/gems/1.8/gems/yard-0.5.2/lib/rubygems_plugin.rb:79:in `install_ri'
/usr/local/lib/site_ruby/1.8/rubygems/doc_manager.rb:109:in `generate_ri'
...

yard's maintainer has added a fix, but it only works going forward(since Gem.find_files returns the newer one first).

I wrote something that fixes the problem by replacing /lib/rubygems.rb:1103, but it is kind of ugly due to my unfamiliarity with rubygems internals.

plugins = Gem.latest_load_paths.map do |path|
      path = path+'/rubygems_plugin.rb'
      path if File.exists? path
    end.compact

my notes are also at http://gist.github.com/281456

Thanks,

Nick Howard

----------------------------------------------------------------------

>Comment By: Eric Hodel (drbrain)
Date: 2010-01-21 01:39

Message:
This behavior is clearly spelled out in the documentation:

# == RubyGems Plugins
#
# As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
# $LOAD_PATH.  Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
# placed at the root of your gem's #require_path.  Plugins are discovered via
# Gem::find_files then loaded.  Take care when implementing a plugin as your
# plugin file may be loaded multiple times if multiple versions of your gem
# are installed.

I'm sorry that it has inconvenienced yard, but rubygems_plugin.rb is not a place to fill with random code (See http://github.com/lsegal/yard/blob/master/lib/rubygems_plugin.rb).  You need to restrict yourself to requiring the files you need and nothing more.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=27712&group_id=126


More information about the Rubygems-developers mailing list