summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-02-22 07:37:41 +0000
committerBundlerbot <bot@bundler.io>2019-02-22 07:37:41 +0000
commit552d0952828ecd3f1e50b3345f5293096139d8ae (patch)
treeb874f7de6616779776bb4703976095a403a6b4b0
parent6ce532267500a13cb855021fad93920e9f940baa (diff)
parentfda9db6b3cd5af72f4d11927116ca5f027c16eb4 (diff)
downloadbundler-552d0952828ecd3f1e50b3345f5293096139d8ae.tar.gz
Merge #6965
6965: Turn on deprecations by default r=indirect a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was we've had deprecations in place for a long time, but we've never displayed them to users by default. ### What was your diagnosis of the problem? My diagnosis was that the current strategy doesn't work because: * Printing deprecations as an optin feature almost never get enabled, so most users don't know about the stuff we'll be deprecating in the future. * Printing deprecations in "deprecation releases" doesn't work well either, because it's unclear how long the deprecation release should last and thus how long we need to hold the final release (that will inhibit installation of the deprecation release). ### What is your fix for the problem, implemented in this PR? My fix is to remove the concept of deprecation releases, and to add a feature flag for printing major deprecations that it's enabled by default. As a extra related change, I also reworded the deprecation messages, because I find the current message "[DEPRECATED FOR 2.0] <Message about the deprecation>" a bit confusing because it's unclear what the version printed is referring to (deprecation horizon? current running version?), so I changed it to just "[DEPRECATED] <Message about the deprecation>". ### Why did you choose this fix out of the possible options? I chose this fix because it (once released) finally makes it so that users will know about our deprecations. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--lib/bundler/settings.rb3
-rw-r--r--lib/bundler/shared_helpers.rb9
-rw-r--r--man/bundle-config.ronn6
-rw-r--r--spec/commands/show_spec.rb8
-rw-r--r--spec/install/gemfile/sources_spec.rb3
-rw-r--r--spec/install/redownload_spec.rb12
-rw-r--r--spec/other/major_deprecation_spec.rb18
-rw-r--r--spec/runtime/with_unbundled_env_spec.rb16
-rw-r--r--spec/support/matchers.rb2
-rw-r--r--spec/update/redownload_spec.rb12
10 files changed, 34 insertions, 55 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 79690d31aa..ff9a5f57af 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -41,7 +41,6 @@ module Bundler
init_gems_rb
list_command
lockfile_uses_separate_rubygems_sources
- major_deprecations
no_install
no_prune
only_update_to_newer_versions
@@ -52,6 +51,7 @@ module Bundler
prefer_patch
print_only_version_number
setup_makes_kernel_gem_public
+ silence_deprecations
silence_root_warning
skip_default_git_sources
specific_platform
@@ -76,6 +76,7 @@ module Bundler
].freeze
DEFAULT_CONFIG = {
+ :silence_deprecations => false,
:disable_version_check => true,
:prefer_patch => false,
:redirect => 5,
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 02b3801c44..ed88caf8cf 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -144,13 +144,13 @@ module Bundler
bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version
require "bundler/errors"
- raise DeprecatedError, "[REMOVED FROM #{major_version.succ}.0] #{message}"
+ raise DeprecatedError, "[REMOVED] #{message}"
end
- return unless bundler_major_version >= major_version || prints_major_deprecations?
+ return unless bundler_major_version >= major_version && prints_major_deprecations?
@major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
- ui.warn("[DEPRECATED FOR #{major_version}.0] #{message}")
+ ui.warn("[DEPRECATED] #{message}")
end
def print_major_deprecations!
@@ -374,8 +374,7 @@ module Bundler
def prints_major_deprecations?
require "bundler"
- deprecation_release = Bundler::VERSION.split(".").drop(1).include?("99")
- return false if !deprecation_release && !Bundler.settings[:major_deprecations]
+ return false if Bundler.settings[:silence_deprecations]
require "bundler/deprecate"
return false if Bundler::Deprecate.skip
true
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index 64f0fea743..0b61cbeca0 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -210,9 +210,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
The number of gems Bundler can install in parallel. Defaults to 1.
* `list_command` (`BUNDLE_LIST_COMMAND`)
Enable new list command feature
-* `major_deprecations` (`BUNDLE_MAJOR_DEPRECATIONS`):
- Whether Bundler should print deprecation warnings for behavior that will
- be changed in the next major version.
* `no_install` (`BUNDLE_NO_INSTALL`):
Whether `bundle package` should skip installing gems.
* `no_prune` (`BUNDLE_NO_PRUNE`):
@@ -247,6 +244,9 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `shebang` (`BUNDLE_SHEBANG`):
The program name that should be invoked for generated binstubs. Defaults to
the ruby install name used to generate the binstub.
+* `silence_deprecations` (`BUNDLE_SILENCE_DEPRECATIONS`):
+ Whether Bundler should silence deprecation warnings for behavior that will
+ be changed in the next major version.
* `silence_root_warning` (`BUNDLE_SILENCE_ROOT_WARNING`):
Silence the warning Bundler prints when installing gems as root.
* `skip_default_git_sources` (`BUNDLE_SKIP_DEFAULT_GIT_SOURCES`):
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index 08b106d0a0..6692fb0cfb 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe "bundle show" do
it "prints deprecation", :bundler => "2" do
bundle "show rails"
- expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`")
+ expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`")
end
it "prints path if gem exists in bundle (with --paths option)" do
@@ -42,7 +42,7 @@ RSpec.describe "bundle show" do
it "prints deprecation when called with a gem and the --paths option", :bundler => "2" do
bundle "show rails --paths"
- expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`")
+ expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`")
end
it "warns if path no longer exists on disk" do
@@ -61,7 +61,7 @@ RSpec.describe "bundle show" do
it "prints deprecation when called with bundler", :bundler => "2" do
bundle "show bundler"
- expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`")
+ expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`")
end
it "complains if gem not in bundle" do
bundle "show missing"
@@ -82,7 +82,7 @@ RSpec.describe "bundle show" do
it "prints a deprecation when called with the --paths option", :bundler => 2 do
bundle "show --paths"
- expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle list` instead of `bundle show --paths`")
+ expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`")
end
it "prints summary of gems" do
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 0af77cf862..c8f46e48c8 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -25,7 +25,6 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack"
G
- bundle "config set major_deprecations true"
end
it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 2" do
@@ -55,7 +54,6 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack", "1.0.0" # force it to install the working version in repo1
G
- bundle "config set major_deprecations true"
end
it "warns about ambiguous gems, but installs anyway", :bundler => "< 2" do
@@ -249,7 +247,6 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
it "installs from the other source and warns about ambiguous gems", :bundler => "< 2" do
- bundle "config set major_deprecations true"
bundle :install
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
diff --git a/spec/install/redownload_spec.rb b/spec/install/redownload_spec.rb
index 141a2e80d5..de726c4562 100644
--- a/spec/install/redownload_spec.rb
+++ b/spec/install/redownload_spec.rb
@@ -63,22 +63,22 @@ RSpec.describe "bundle install" do
it "shows a deprecation when single flag passed", :bundler => 2 do
bundle! "install --force"
- expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "shows a deprecation when multiple flags passed", :bundler => 2 do
bundle! "install --no-color --force"
- expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single flag passed", :bundler => "< 2" do
bundle! "install --force"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
bundle! "install --no-color --force"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
@@ -89,12 +89,12 @@ RSpec.describe "bundle install" do
it "does not show a deprecation when single flag passed" do
bundle! "install --redownload"
- expect(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle! "install --no-color --redownload"
- expect(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index 800c7b4b88..6e278dc45d 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -4,25 +4,7 @@ RSpec.describe "major deprecations", :bundler => "< 2" do
let(:warnings) { last_command.bundler_err } # change to err in 2.0
let(:warnings_without_version_messages) { warnings.gsub(/#{Spec::Matchers::MAJOR_DEPRECATION}Bundler will only support ruby(gems)? >= .*/, "") }
- context "in a .99 version" do
- before do
- simulate_bundler_version "1.99.1"
- bundle "config unset major_deprecations"
- end
-
- it "prints major deprecations without being configured" do
- ruby <<-R
- require "bundler"
- Bundler::SharedHelpers.major_deprecation(Bundler::VERSION)
- R
-
- expect(warnings).to have_major_deprecation("1.99.1")
- end
- end
-
before do
- bundle "config set major_deprecations true"
-
create_file "gems.rb", <<-G
source "file:#{gem_repo1}"
ruby #{RUBY_VERSION.dump}
diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb
index 5ddcc24ed4..605bed8254 100644
--- a/spec/runtime/with_unbundled_env_spec.rb
+++ b/spec/runtime/with_unbundled_env_spec.rb
@@ -106,8 +106,8 @@ RSpec.describe "Bundler.with_env helpers" do
it "prints a deprecation", :bundler => 2 do
code = "Bundler.clean_env"
bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to include(
- "[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
+ expect(err).to include(
+ "[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
)
end
@@ -115,8 +115,8 @@ RSpec.describe "Bundler.with_env helpers" do
it "does not print a deprecation", :bundler => "< 2" do
code = "Bundler.clean_env"
bundle_exec_ruby! code.dump
- expect(last_command.stdboth).not_to include(
- "[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
+ expect(out).not_to include(
+ "[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
)
end
@@ -156,8 +156,8 @@ RSpec.describe "Bundler.with_env helpers" do
it "prints a deprecation", :bundler => 2 do
code = "Bundler.with_clean_env {}"
bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to include(
- "[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
+ expect(err).to include(
+ "[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
)
end
@@ -165,8 +165,8 @@ RSpec.describe "Bundler.with_env helpers" do
it "does not print a deprecation", :bundler => "< 2" do
code = "Bundler.with_clean_env {}"
bundle_exec_ruby! code.dump
- expect(last_command.stdboth).not_to include(
- "[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
+ expect(out).not_to include(
+ "[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
)
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 18ccf38fb1..c39f2881a6 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -60,7 +60,7 @@ module Spec
end
end
- MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/
+ MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/
RSpec::Matchers.define :eq_err do |expected|
diffable
diff --git a/spec/update/redownload_spec.rb b/spec/update/redownload_spec.rb
index 2653d5d1a3..b70c009248 100644
--- a/spec/update/redownload_spec.rb
+++ b/spec/update/redownload_spec.rb
@@ -11,34 +11,34 @@ RSpec.describe "bundle update" do
describe "with --force" do
it "shows a deprecation when single flag passed", :bundler => 2 do
bundle! "update rack --force"
- expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "shows a deprecation when multiple flags passed", :bundler => 2 do
bundle! "update rack --no-color --force"
- expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single flag passed", :bundler => "< 2" do
bundle! "update rack --force"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
bundle! "update rack --no-color --force"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
describe "with --redownload" do
it "does not show a deprecation when single flag passed" do
bundle! "update rack --redownload"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle! "update rack --no-color --redownload"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end