Skip to content

Commit 9e44b5e

Browse files
committed
Add informational message when default_cli_command is unset.
1 parent f3f505c commit 9e44b5e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

bundler/lib/bundler/cli.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ def install_or_cli_help
131131
def self.default_command(meth = nil)
132132
return super if meth
133133

134+
unless Bundler.settings[:default_cli_command]
135+
Bundler.ui.info <<-MSG
136+
In the feature version of Bundler, running `bundle` without argument will no longer run `bundle install`.
137+
Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
138+
If you wish to use feature behavior now with `bundle config set default_cli_command cli_help --global`
139+
or you can continue to use the old behavior with `bundle config set default_cli_command install_or_cli_help --global`.
140+
This message will be removed after a default_cli_command value is set.
141+
MSG
142+
end
143+
134144
Bundler.settings[:default_cli_command] || "install_or_cli_help"
135145
end
136146

bundler/spec/bundler/cli_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,21 @@ def out_with_macos_man_workaround
9090
it "tries to installs by default but print help on missing Gemfile" do
9191
bundle "", raise_on_error: false
9292
expect(err).to include("Could not locate Gemfile")
93+
expect(out).to include("In the feature version of Bundler")
9394

9495
expect(out).to include("Bundler version #{Bundler::VERSION}").
9596
and include("\n\nBundler commands:\n\n").
9697
and include("\n\n Primary commands:\n").
9798
and include("\n\n Utilities:\n").
9899
and include("\n\nOptions:\n")
99100
end
101+
102+
it "runs bundle install when default_cli_command set to install" do
103+
bundle "config set default_cli_command install_or_cli_help"
104+
bundle "", raise_on_error: false
105+
expect(out).to_not include("In the feature version of Bundler")
106+
expect(err).to include("Could not locate Gemfile")
107+
end
100108
end
101109

102110
context "when ENV['BUNDLE_GEMFILE'] is set to an empty string" do

0 commit comments

Comments
 (0)