carlhuda/bundler — Issue #1565: ensure_equivalent_gemfile_and_lockfile broken when used with gem.add_development_dependency from a gemspec file
Author: patshaughnessy
Created: 2011-11-30 22:02:58+00:00
State: open

Steps to reproduce:

- bundle gem some_gem_name
- cd some_gem_name
- Note there is a "gemspec" keyword in the Gemfile
- Add any development dependency to the some_gem_name.gemspec file, example: gem.add_development_dependency "faker"
- Run bundle install

everything is fine so far…

Now switch to deployment mode:

bundle config frozen 1

bundle install
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the Gemfile freeze
by running `bundle install --no-deployment`.

You have added to the Gemfile:
* faker

You have deleted from the Gemfile:
* faker

This error occurs forever in deployment mode, even though the Gemfile, gemspec file, and the Gemfile.lock are all in sync.

The problem is caused by line 39 in lib/bundler/dsl.rb, which sets the type of all development dependencies declared in a gemspec file to be type == :development:

group(development_group) do
spec.development_dependencies.each do |dep|
gem dep.name, *(dep.requirement.as_list + [:type => :development])
end
end

This breaks the logic in ensure_equivalent_gemfile_and_lockfile in definition.rb.