Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ def initialize(*args)
end
end

def self.deprecated_option(*args, &blk)
return if Bundler.feature_flag.forget_cli_options?
method_option(*args, &blk)
end

check_unknown_options!(:except => [:config, :exec])
stop_on_unknown_option! :exec

Expand Down Expand Up @@ -142,7 +137,7 @@ def self.handle_no_command_error(command, has_namespace = $thor_runner)
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
dependency listed in the gemspec file to the newly created Gemfile.
D
deprecated_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
def init
require "bundler/cli/init"
Init.new(options.dup).run
Expand Down Expand Up @@ -188,13 +183,13 @@ def remove(*gems)

If the bundle has already been installed, bundler will tell you so and then exit.
D
deprecated_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
"Generate bin stubs for bundled gems to ./bin"
deprecated_option "clean", :type => :boolean, :banner =>
method_option "clean", :type => :boolean, :banner =>
"Run bundle clean automatically after install"
deprecated_option "deployment", :type => :boolean, :banner =>
method_option "deployment", :type => :boolean, :banner =>
"Install using defaults tuned for deployment environments"
deprecated_option "frozen", :type => :boolean, :banner =>
method_option "frozen", :type => :boolean, :banner =>
"Do not allow the Gemfile.lock to be updated after this install"
method_option "full-index", :type => :boolean, :banner =>
"Fall back to using the single-file index of all gems"
Expand All @@ -204,32 +199,37 @@ def remove(*gems)
"Specify the number of jobs to run in parallel"
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
deprecated_option "no-cache", :type => :boolean, :banner =>
method_option "no-cache", :type => :boolean, :banner =>
"Don't update the existing gem cache."
method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
"Force downloading every gem."
deprecated_option "no-prune", :type => :boolean, :banner =>
method_option "no-prune", :type => :boolean, :banner =>
"Don't remove stale gems from the cache."
deprecated_option "path", :type => :string, :banner =>
method_option "path", :type => :string, :banner =>
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
method_option "quiet", :type => :boolean, :banner =>
"Only output warnings and errors."
deprecated_option "shebang", :type => :string, :banner =>
method_option "shebang", :type => :string, :banner =>
"Specify a different shebang executable name than the default (usually 'ruby')"
method_option "standalone", :type => :array, :lazy_default => [], :banner =>
"Make a bundle that can work without the Bundler runtime"
deprecated_option "system", :type => :boolean, :banner =>
method_option "system", :type => :boolean, :banner =>
"Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
method_option "trust-policy", :alias => "P", :type => :string, :banner =>
"Gem trust policy (like gem install -P). Must be one of " +
Bundler.rubygems.security_policy_keys.join("|")
deprecated_option "without", :type => :array, :banner =>
method_option "without", :type => :array, :banner =>
"Exclude gems that are part of the specified named group."
deprecated_option "with", :type => :array, :banner =>
method_option "with", :type => :array, :banner =>
"Include gems that are part of the specified named group."
map "i" => "install"
def install
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")

%w[clean deployment frozen no-cache no-prune path shebang system without with].each do |option|
remembered_flag_deprecation(option)
end

require "bundler/cli/install"
Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run
Expand Down Expand Up @@ -786,5 +786,22 @@ def warn_on_outdated_bundler
rescue RuntimeError
nil
end

def remembered_flag_deprecation(name)
option = current_command.options[name]
flag_name = option.switch_name

name_index = ARGV.find {|arg| flag_name == arg }
return unless name_index

value = options[name]
value = value.join(" ").to_s if option.type == :array

Bundler::SharedHelpers.major_deprecation 2,\
"The `#{flag_name}` flag is deprecated because it relied on being " \
"remembered accross bundler invokations, which bundler will no longer " \
"do in future versions. Instead please use `bundle config #{name} " \
"'#{value}'`, and stop using this flag"
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.settings_method(name, key, &default)
settings_flag(:deployment_means_frozen) { bundler_2_mode? }
settings_flag(:disable_multisource) { bundler_2_mode? }
settings_flag(:error_on_stderr) { bundler_2_mode? }
settings_flag(:forget_cli_options) { bundler_2_mode? }
settings_flag(:forget_cli_options) { bundler_3_mode? }
settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? }
settings_flag(:global_gem_cache) { bundler_2_mode? }
settings_flag(:init_gems_rb) { bundler_2_mode? }
Expand Down
18 changes: 13 additions & 5 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,19 @@ def set_command_option(key, value)
"bundle config set #{key} #{Array(value).join(":")}"
end

Bundler::SharedHelpers.major_deprecation 2,\
"flags passed to commands " \
"will no longer be automatically remembered. Instead please set flags " \
"you want remembered between commands using `bundle config set " \
"<setting name> <setting value>`, i.e. `#{command}`"
unless Bundler.settings[:forget_cli_options] == false
Bundler::SharedHelpers.major_deprecation 3,\
"flags passed to commands " \
"will no longer be automatically remembered. Instead please set flags " \
"you want remembered between commands using `bundle config set " \
"<setting name> <setting value>`, i.e. `#{command}`. Once you are " \
"ready for the new behavior, use `bundle config set forget_cli_options " \
"true` to get rid of this message. Or if you want to get rid of " \
"this message and stick with the old behavior for now, run " \
"`bundle config set forget_cli_options false`, but keep in mind " \
"that this behavior will be fully removed in future versions of " \
"bundler."
end

set_local(key, value)
end
Expand Down
38 changes: 37 additions & 1 deletion spec/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
end

context "with flags" do
xit "should print a deprecation warning about autoremembering flags" do
it "should print a deprecation warning about autoremembering flags", :bundler => "3" do
install_gemfile <<-G, :path => "vendor/bundle"
source "file://#{gem_repo1}"
gem "rack"
Expand All @@ -121,6 +121,42 @@
"flags passed to commands will no longer be automatically remembered."
)
end

{
:clean => true,
:deployment => true,
:frozen => true,
:"no-cache" => true,
:"no-prune" => true,
:path => "vendor/bundle",
:shebang => "ruby27",
:system => true,
:without => "development",
:with => "development",
}.each do |name, value|
flag_name = "--#{name}"

context "with the #{flag_name} flag", :bundler => "2" do
it "should print a deprecation warning" do
bundle "install #{flag_name} #{value}"

expect(warnings).to have_major_deprecation(
"The `#{flag_name}` flag is deprecated because it relied on " \
"being remembered accross bundler invokations, which bundler " \
"will no longer do in future versions. Instead please use " \
"`bundle config #{name} '#{value}'`, and stop using this flag"
)
end
end

context "with the #{flag_name} flag", :bundler => "< 2" do
it "should not print a deprecation warning" do
bundle "install #{flag_name} #{value}"

expect(warnings).not_to have_major_deprecation
end
end
end
end
end

Expand Down