carlhuda/bundler — Issue #1481: gemspec loaded too many times => slowdown!
Author: sunaku
Created: 2011-10-14 06:34:13+00:00
State: open

The `bundle` commands are loading my project's gemspec multiple times, as demonstrated simply below. Fixing this might speed up bundler's responsiveness and make people (or me, at the very least) happier! Thanks for your consideration.

```bash
/tmp> ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

/tmp> gem --version
1.8.11

/tmp> bundle --version
Bundler version 1.0.21

/tmp> bundle gem bugreport
create bugreport/Gemfile
create bugreport/Rakefile
create bugreport/.gitignore
create bugreport/bugreport.gemspec
create bugreport/lib/bugreport.rb
create bugreport/lib/bugreport/version.rb
Initializating git repo in /tmp/bugreport

/tmp> cd bugreport

/tmp/bugreport> sed -i '$s/.*/ puts nil, caller, nil\n&/' bugreport.gemspec

####### NOTE: RUNNING BUNDLE THE FIRST TIME #########

/tmp/bugreport> bundle

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:32:in `gemspec'
/tmp/bugreport/Gemfile:4:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `instance_eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in `build'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:138:in `definition'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:353:in `block in load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:385:in `local_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:356:in `block in converge_locked_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:345:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:345:in `converge_locked_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:143:in `resolve'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:90:in `specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:85:in `resolve_remotely!'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:43:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:8:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

Fetching source index for http://rubygems.org/
Using bugreport (0.0.1) from source at /tmp/bugreport
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

####### NOTE: RUNNING BUNDLE THE SECOND TIME #########

/tmp/bugreport> bundle

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:32:in `gemspec'
/tmp/bugreport/Gemfile:4:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `instance_eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in `build'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:138:in `definition'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:32:in `gemspec'
/tmp/bugreport/Gemfile:4:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `instance_eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `evaluate'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in `build'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:32:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:8:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:353:in `block in load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:385:in `local_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:372:in `block in converge_locked_specs'
/usr/lib/ruby/1.9.1/forwardable.rb:182:in `each'
/usr/lib/ruby/1.9.1/forwardable.rb:182:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:361:in `converge_locked_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:143:in `resolve'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:116:in `missing_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:33:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:8:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1346:in `initialize'
/tmp/bugreport/bugreport.gemspec:5:in `new'
/tmp/bugreport/bugreport.gemspec:5:in `

'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `eval'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:241:in `rescue in block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:236:in `block in load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `chdir'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler.rb:234:in `load_gemspec'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:353:in `block in load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:352:in `load_spec_files'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/source.rb:385:in `local_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:372:in `block in converge_locked_specs'
/usr/lib/ruby/1.9.1/forwardable.rb:182:in `each'
/usr/lib/ruby/1.9.1/forwardable.rb:182:in `each'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:361:in `converge_locked_specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:143:in `resolve'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/definition.rb:90:in `specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/environment.rb:27:in `specs'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:49:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/installer.rb:8:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
/home/sunny/app/rubygems/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
/home/sunny/app/rubygems/gems/bundler-1.0.21/bin/bundle:13:in `'
/home/sunny/app/rubygems/bin/bundle:19:in `load'
/home/sunny/app/rubygems/bin/bundle:19:in `

'

Using bugreport (0.0.1) from source at .
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
```