rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 1.99k forks source link

Bundler removes more than it should #7659

Closed josemigallas closed 4 years ago

josemigallas commented 4 years ago

Description When removing a gem from my Gemfile with bundle remove capybara, it results in the following diff:

$ git diff Gemfile.base
diff --git a/Gemfile.base b/Gemfile.base
index 9e2a96b69..cb3f42794 100644
--- a/Gemfile.base
+++ b/Gemfile.base
@@ -177,9 +177,6 @@ group :development do
   gem 'yard', require: false
   # Install rubocop only when using RubyMine (for the rubocop plugin)
-  gem 'rubocop', '0.59.1', install_if: ENV['TEAMCITY_RAKE_RUNNER_MODE'], require: false
-end
-
 gem 'message_bus', '~> 2.0.2'
 gem 'message_bus_client', github: '3scale/message_bus_client'
@@ -196,7 +193,6 @@ group :test do
   gem 'rack-no_animations', '~> 1.0.3'
   gem 'simplecov', '~> 0.10.0'
-  gem 'capybara', '~> 2.18', source: 'https://rubygems.org'
   gem 'xpath', '~>2.1'
   gem 'selenium-webdriver', '~> 3.142', require: false
@@ -258,9 +254,6 @@ group :development, :test do
   gem 'sour', github: 'HakubJozak/sour', require: false
   # for `rake doc:liquid:generate` and similar
-  gem 'source2swagger', git: 'https://github.com/3scale/source2swagger'
-end
-
 gem 'webpacker', '~> 4.x'
 gem 'unicorn', require: false, group: [:production, :preview]

The output of the command being:

$ bundle remove capybara
Removing gems from /Users/jgallaso/Projects/3scale/porta/Gemfile
capybara (~> 2.18) was removed.
Removing gems from /Users/jgallaso/Projects/3scale/porta/Gemfile.base
[!] There was an error parsing `Gemfile.base`: syntax error, unexpected end-of-input, expecting keyword_end - gem 'kubeclient'
                ^. Bundler cannot continue.
 #  from /Users/jgallaso/Projects/3scale/porta/Gemfile.base:267
 #  -------------------------------------------
 #
 >  gem 'kubeclient'
 #  -------------------------------------------
$ bundle remove capybara
Removing gems from /Users/jgallaso/Projects/3scale/porta/Gemfile
capybara (~> 2.18) was removed.
Removing gems from /Users/jgallaso/Projects/3scale/porta/Gemfile.base
[!] There was an error parsing `Gemfile.base`: syntax error, unexpected end-of-input, expecting keyword_end - gem 'kubeclient'
                ^. Bundler cannot continue.
 #  from /Users/jgallaso/Projects/3scale/porta/Gemfile.base:267
 #  -------------------------------------------
 #
 >  gem 'kubeclient'
 #  -------------------------------------------

My findings so far: Apparently the only afffected gems are rubocop and source2swagger and only when located at the end of each group. Also if removing them, the end keyword is not removed, for example bundle remove rubocop will result in:

$ git diff Gemfile.base
diff --git a/Gemfile.base b/Gemfile.base
index 9e2a96b69..c7aa53a22 100644
--- a/Gemfile.base
+++ b/Gemfile.base
@@ -177,7 +177,6 @@ group :development do
   gem 'yard', require: false

   # Install rubocop only when using RubyMine (for the rubocop plugin)
-  gem 'rubocop', '0.59.1', install_if: ENV['TEAMCITY_RAKE_RUNNER_MODE'], require: false
 end

 gem 'message_bus', '~> 2.0.2'
@@ -258,9 +257,6 @@ group :development, :test do
   gem 'sour', github: 'HakubJozak/sour', require: false

   # for `rake doc:liquid:generate` and similar
-  gem 'source2swagger', git: 'https://github.com/3scale/source2swagger'
-end
-
 gem 'webpacker', '~> 4.x'

 gem 'unicorn', require: false, group: [:production, :preview]

Env: Bundler version 1.17.3 ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin19]

colby-swandale commented 4 years ago

I ran $ bundle remove capybara on the given Gemfile with Bundler 2.1.4 which behaved as expected. Can you try this on the latest Bundler version and let us know the result?

$ bundle remove capybara
Removing gems from /Users/colby/Desktop/test/Gemfile
capybara (~> 2.18) was removed.
$ git diff
─────────────────────────────────────────────────────────────────────────────────────────────────────
modified: Gemfile
─────────────────────────────────────────────────────────────────────────────────────────────────────
@ Gemfile:199 @ group :test do
  gem 'rack-no_animations', '~> 1.0.3'
  gem 'simplecov', '~> 0.10.0'

- gem 'capybara', '~> 2.18', source: 'https://rubygems.org'
  gem 'xpath', '~>2.1'

  gem 'selenium-webdriver', '~> 3.142', require: false