Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

duplicate dependencies in Gemfile.lock on bundle update #5599

Closed
embark opened this issue Apr 19, 2017 · 4 comments
Closed

duplicate dependencies in Gemfile.lock on bundle update #5599

embark opened this issue Apr 19, 2017 · 4 comments
Assignees
Milestone

Comments

@embark
Copy link

embark commented Apr 19, 2017

Error Report

Questions

What did you do?
I ran the commands:

  • with the Gemfile and environment listed below
  • bundle
  • gem uninstall responders
  • bundle update easypost

What did you expect to happen?
I expected Bundler to create a Gemfile.lock after bundle update easypost that was identical to the Gemfile.lock right after bundle

What happened instead?
Instead, Bundler duplicated responders in the gemfile:

...
     responders (2.3.0)
       railties (>= 4.2.0, < 5.1)
+    responders (2.3.0)
+      railties (>= 4.2.0, < 5.1)
     rest-client (2.0.1)
       http-cookie (>= 1.0.2, < 2.0)
...

NOTE: this only happened when using a block with the source, not if the source was just listed at the top of the Gemfile.

Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?
Couldn't find any similar issues, but might have missed it.

Environment

Bundler   1.14.6
Rubygems  2.5.2
Ruby      2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin16]
GEM_HOME  ~/.rvm/gems/ruby-2.3.4
GEM_PATH  ~/.rvm/gems/ruby-2.3.4:~/.rvm/gems/ruby-2.3.4@global
RVM       1.27.0 (latest)
Git       2.11.0
Platform  x86_64-darwin-16

Bundler settings

build.puma
  Set for the current user (~/.bundle/config): "--with-opt-dir=/usr/local/opt/openssl"
build.eventmachine
  Set for the current user (~/.bundle/config): "--with-opt-dir=/usr/local/opt/openssl"

Gemfile

Gemfile

source 'https://rubygems.org/' do
  gem 'easypost'
  gem 'responders'
end

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actionpack (5.0.2)
      actionview (= 5.0.2)
      activesupport (= 5.0.2)
      rack (~> 2.0)
      rack-test (~> 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.0.2)
      activesupport (= 5.0.2)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activesupport (5.0.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (~> 0.7)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    builder (3.2.3)
    concurrent-ruby (1.0.5)
    domain_name (0.5.20170404)
      unf (>= 0.0.5, < 1.0.0)
    easypost (2.7.0)
      multi_json (>= 1.3.0)
      rest-client (>= 1.4)
    erubis (2.7.0)
    http-cookie (1.0.3)
      domain_name (~> 0.5)
    i18n (0.8.1)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    method_source (0.8.2)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mini_portile2 (2.1.0)
    minitest (5.10.1)
    multi_json (1.12.1)
    netrc (0.11.0)
    nokogiri (1.7.1)
      mini_portile2 (~> 2.1.0)
    rack (2.0.1)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails-dom-testing (2.0.2)
      activesupport (>= 4.2.0, < 6.0)
      nokogiri (~> 1.6)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (5.0.2)
      actionpack (= 5.0.2)
      activesupport (= 5.0.2)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.0.0)
    responders (2.3.0)
      railties (>= 4.2.0, < 5.1)
    rest-client (2.0.1)
      http-cookie (>= 1.0.2, < 2.0)
      mime-types (>= 1.16, < 4.0)
      netrc (~> 0.8)
    thor (0.19.4)
    thread_safe (0.3.6)
    tzinfo (1.2.3)
      thread_safe (~> 0.1)
    unf (0.1.4)
      unf_ext
    unf_ext (0.0.7.4)

PLATFORMS
  ruby

DEPENDENCIES
  easypost!
  responders!

BUNDLED WITH
   1.14.6
@xaviershay
Copy link
Contributor

I was able to repro. FWIW, running bundle again afterwards reverts the extra responders line.

@segiddins
Copy link
Member

segiddins commented Apr 20, 2017

Thanks!
The fix is as follows (but will require a test):

diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 5fd6bd606..c9b53a00c 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -110,7 +110,7 @@ module Bundler
     def merge(set)
       arr = sorted.dup
       set.each do |s|
-        next if arr.any? {|s2| s2.name == s.name && s2.version == s.version && s2.platform == s.platform }
+        next if arr.any? {|s2| s.full_name == s2.full_name }
         arr << s
       end
       SpecSet.new(arr)

(the root cause being I'm guessing a spec has a platform of nil and another of Gem::Platform::RUBY)

@segiddins
Copy link
Member

#5600 should fix this, thanks for the thorough bug report!

@embark
Copy link
Author

embark commented Apr 20, 2017

Wow thank you for the super fast fix!

@segiddins segiddins added this to the 1.15.0.pre.2 milestone Apr 20, 2017
bundlerbot added a commit that referenced this issue Apr 21, 2017
Avoid duplicating specs in the lockfile after updating w/ the gem uninstalled

Closes #5599

I decided to not compare using `full_name` in `SpecSet#merge` for the sake of performance, since `#full_name` is uncached
segiddins pushed a commit that referenced this issue Apr 23, 2017
Avoid duplicating specs in the lockfile after updating w/ the gem uninstalled

Closes #5599

I decided to not compare using `full_name` in `SpecSet#merge` for the sake of performance, since `#full_name` is uncached

(cherry picked from commit 8e2cd4a)
philipefarias added a commit to dleemoo/rc-images that referenced this issue Jun 12, 2017
Changes since last version used (1.14.6):

== 1.15.1 (2017-06-02)

Bugfixes:

  - `bundle lock --update GEM` will fail gracefully when the gem is not in the lockfile (rubygems/bundler#5693, @segiddins)
  - `bundle init --gemspec` will fail gracefully when the gemspec is invalid (@colby-swandale)
  - `bundle install --force` works when the gemfile contains git gems (rubygems/bundler#5678, @segiddins)
  - `bundle env` will print well-formed markdown when there are no settings (rubygems/bundler#5677, @segiddins)

== 1.15.0 (2017-05-19)

This space intentionally left blank.

== 1.15.0.pre.4 (2017-05-10)

Bugfixes:

  - avoid conflicts when `Gem.finish_resolve` is called after the bundle has been set up (@segiddins)
  - ensure that `Gem::Specification.find_by_name` always returns an object that can have `#to_spec` called on it (rubygems/bundler#5592, @jules2689)

== 1.15.0.pre.3 (2017-04-30)

Bugfixes:

  - avoid redundant blank lines in the readme generated by `bundle gem` (@koic)
  - ensure that `open-uri` is not loaded after `bundle exec` (@segiddins)
  - print a helpful error message when an activated default gem conflicts with
    a gem in the gemfile (@segiddins)
  - only shorten `ref` option for git gems when it is a SHA (rubygems/bundler#5620, @segiddins)

== 1.15.0.pre.2 (2017-04-23)

Bugfixes:

  - ensure pre-existing fit caches are updated from remote sources (rubygems/bundler#5423, @alextaylor000)
  - avoid duplicating specs in the lockfile after updating with the gem uninstalled (rubygems/bundler#5599, @segiddins)
  - ensure git gems have their extensions available at runtime (rubygems/bundler#5594, @jules2689, @segiddins)

== 1.15.0.pre.1 (2017-04-16)

Features:

  - print a notification when a newer version of bundler is available (rubygems/bundler#4683, @segiddins)
  - add man pages for all bundler commands (rubygems/bundler#4988, @feministy)
  - add the `bundle info` command (@fredrb, @colby-swandale)
  - all files created with `bundle gem` comply with the bundler style guide (@zachahn)
  - if installing a gem fails, print out the reason the gem needed to be installed (rubygems/bundler#5078, @segiddins)
  - allow setting `gem.push_key` to set the key used when running `rake release` (@DTrierweiler)
  - print gem versions that are regressing during `bundle update` in yellow (rubygems/bundler#5506, @brchristian)
  - avoid printing extraneous dependencies when the resolver encounters a conflict (@segiddins)
  - add the `bundle issue` command that prints instructions for reporting issues (rubygems/bundler#4871, @jonathanpike)
  - add `--source` and `--group` options to the `bundle inject` command (rubygems/bundler#5452, @Shekharrajak)
  - add the `bundle add` command to add a gem to the gemfile (@denniss)
  - add the `bundle pristine` command to re-install gems from cached `.gem` files (rubygems/bundler#4509, @denniss)
  - add a `--parseable` option for `bundle config` (@JuanitoFatas, @colby-swandale)

Performance:

  - speed up gemfile initialization by storing locked dependencies as a hash (@jules2689)
  - speed up gemfile initialization by making locked dependency comparison lazy, avoiding object allocation (@jules2689)
  - only validate git gems when they are downloaded, instead of every time `Bundler.setup` is run (@segiddins)
  - avoid regenerating the lockfile when nothing has changed (@segiddins)
  - avoid diffing large arrays when no sources in the gemfile have changed (@segiddins)
  - avoid evaluating full gemspecs when running with RubyGems 2.5+ (@segiddins)

Bugfixes:

  - fix cases where `bundle update` would print a resolver conflict instead of updating the selected gems (rubygems/bundler#5031, rubygems/bundler#5095, @segiddins)
  - print out a stack trace after an interrupt when running in debug mode (@segiddins)
  - print out when bundler starts fetching a gem from a remote server (@segiddins)
  - fix `bundle gem` failing when `git` is unavailable (rubygems/bundler#5458, @Shekharrajak, @colby-swandale)
  - suggest the appropriate command to unfreeze a bundle (rubygems/bundler#5009, @denniss)
  - ensure nested calls to `bundle exec` resolve default gems correctly (rubygems/bundler#5500, @segiddins)
  - ensure that a plugin failing to install doesn't uninstall other plugins (@kerrizor, @roseaboveit)
  - ensure `socket` is required before being referenced (rubygems/bundler#5533, @rafaelfranca)
  - allow running `bundle outdated` when gems aren't installed locally (rubygems/bundler#5553, @segiddins)
  - print a helpful error when `bundle exec`ing to a gem that isn't included in the bundle (rubygems/bundler#5487, @segiddins)
  - print an error message when a non-git gem is given a `branch` option (rubygems/bundler#5530, @colby-swandale)
  - allow interrupts to exit the process after gems have been installed (@segiddins)
  - print the underlying error when downloading gem metadata fails (rubygems/bundler#5579, @segiddins)
  - avoid deadlocking when installing with a lockfile that is missing dependencies (rubygems/bundler#5378, rubygems/bundler#5480, rubygems/bundler#5519, rubygems/bundler#5526, rubygems/bundler#5529, rubygems/bundler#5549, rubygems/bundler#5572, @segiddins)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants