Skip to content

Commit

Permalink
Trigger install command by default on remove
Browse files Browse the repository at this point in the history
Closes #4889
  • Loading branch information
ceritium committed Sep 3, 2021
1 parent 85d2007 commit 2b17544
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions bundler/lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def check
method_option "install", :type => :boolean, :banner =>
"Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems)
SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
require_relative "cli/remove"
Remove.new(gems, options).run
end
Expand Down
3 changes: 1 addition & 2 deletions bundler/lib/bundler/cli/remove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def run
raise InvalidOption, "Please specify gems to remove." if @gems.empty?

Injector.remove(@gems, {})

Installer.install(Bundler.root, Bundler.definition) if @options["install"]
Installer.install(Bundler.root, Bundler.definition)
end
end
end
3 changes: 2 additions & 1 deletion bundler/spec/commands/remove_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end
end

context "when --install flag is specified" do
context "when --install flag is specified", :bundler => "< 3" do
it "removes gems from .bundle" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
Expand All @@ -40,6 +40,7 @@
bundle "remove rack"

expect(out).to include("rack was removed.")
expect(the_bundle).to_not include_gems "rack"
gemfile_should_be <<-G
source "#{file_uri_for(gem_repo1)}"
G
Expand Down
19 changes: 19 additions & 0 deletions bundler/spec/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,25 @@
end
end

context "bundle remove" do
before do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
end

context "with --install" do
it "shows a deprecation warning", :bundler => "< 3" do
bundle "remove rack --install"

expect(err).to include "[DEPRECATED] The `--install` flag has been deprecated. `bundle install` is triggered by default."
end

pending "fails with a helpful message", :bundler => "3"
end
end

context "bundle console" do
before do
bundle "console", :raise_on_error => false
Expand Down
5 changes: 5 additions & 0 deletions bundler/spec/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def build_repo1
build_repo gem_repo1 do
FileUtils.cp rake_path, "#{gem_repo1}/gems/"

build_gem "coffee-script-source"
build_gem "git"
build_gem "puma"
build_gem "minitest"

build_gem "rack", %w[0.9.1 1.0.0] do |s|
s.executables = "rackup"
s.post_install_message = "Rack's post install message"
Expand Down

0 comments on commit 2b17544

Please sign in to comment.