Load RubyGems plugins #1364

Closed
wants to merge 1 commit into
from

3 participants

@tpope

My use case is gem-ctags, my own gem which automatically invokes ctags on installed gems. It works great on gem install, but doesn't fire on bundle install, and the difference is that Bundler skips loading RubyGems plugins.

My strategy here is to invoke Gem.load_plugins inside bundler/cli, which is basically equivalent to where RubyGems itself does it: rubygems/gem_runner. I don't claim to fully understand the implications of doing it here (or, indeed, doing it all), but it seems benign enough. Bundler.setup never loads this file, so there's no risk of accidentally tainting the pristine environment with additional gems.

@indirect
Bundler member

What's the performance cost of this change?

@tpope

I just tried with about 140 gems installed (none of them RubyGems plugins) and it appears to be negligible. There does not appear to be a measurable penalty for RubyGems plugins either, other than their own load time. For example, adding gem-ctags didn't produce a measurable difference, but adding gem_open raised the overhead by about 0.2 seconds on my machine.

@indirect
Bundler member
@tpope

What if I told you those measurements were on Ruby 1.9.2? You know, the version with poorly scaling require. I just tried again on both 1.8.7 and 1.9.3-preview1 and neither shows a measurable difference.

Happy to discuss the possibility of opt-in if you still think that's the best way.

@retr0h

I'm just an outsider here, but .2 second is fairly small, given bundler is hella slow when fetching rubygems' source index.

@indirect
Bundler member

@tpope, understandable, I just worry about anything that could potentially make Bundler's boot time worse. It seems like the only time when gem plugins could possibly have an effect on Bundler is at install time. This seems to be borne out by the way that your plugin (which is the first plugin-related request I have seen for Bundler) modifies gem installation. In that case, do you think you could move the line that loads the plugins into the install method?

@retr0h, while that is true, we've already stopped fetching the source index in 1.1 (which you can try out with gem install bundler --pre). My goal here is to make Bundler faster over time, rather than saying "fuck it, it's slow already so who cares if it gets even slower!".

@tpope

I'm fine with that. It also needs to go in the update method, correct?

@tpope

I've force pushed a new commit operating under that assumption.

@retr0h

@indirect totally, thats my point. Fix the slowest part first, which you did in 1.1 :) I'm an isolate guy anyways, just figured I would chime in :)

@indirect
Bundler member

So just for future reference: Rubygems 1.3.6 doesn't have Gem.load_plugins. Heh.

@indirect indirect closed this Sep 18, 2011
@tpope

Good catch. I actually went back to make sure that the oldest version of RubyGems supported by Bundler had plugins, but I didn't check for Gem.load_plugins itself. D'oh.

Doesn't this mean we should bump https://github.com/carlhuda/bundler/blob/9ce6a3c7ee60bc4b3d2286f145c9e4c639e8d6dc/bundler.gemspec#L17 to ">= 1.3.7" (or put in an if Gem.respond_to?(:load_plugins) guard)?

@indirect
Bundler member
@hone hone added a commit that referenced this pull request Nov 18, 2011
@hone hone Revert "Merge pull request #1364 from tpope/bundler"
This reverts commit 93942d7, reversing
changes made to 8cf9a6d.

Loading gem plugins can cause bundle install to fail.

Conflicts:

	lib/bundler/cli.rb
8dbf3b9
@hone hone added a commit that referenced this pull request Nov 18, 2011
@hone hone Revert "Merge pull request #1364 from tpope/bundler"
This reverts commit 93942d7, reversing
changes made to 8cf9a6d.

Loading gem plugins can cause bundle install to fail.

Conflicts:

	lib/bundler/cli.rb
4195f48
@mpapis mpapis added a commit to mpapis/bundler that referenced this pull request Nov 19, 2011
@hone hone Revert "Merge pull request #1364 from tpope/bundler"
This reverts commit 93942d7, reversing
changes made to 8cf9a6d.

Loading gem plugins can cause bundle install to fail.

Conflicts:

	lib/bundler/cli.rb

Conflicts:

	lib/bundler/cli.rb
0e00918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment