diff --git a/lib/bundler.rb b/lib/bundler.rb index a4f6671e91..904dcb8467 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -567,7 +567,7 @@ module Bundler end def feature_flag - @feature_flag ||= FeatureFlag.new(VERSION) + @feature_flag ||= FeatureFlag.new(settings[:simulate_version] || VERSION) end def reset! diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb index ffffceb487..444ab6fd37 100644 --- a/lib/bundler/environment_preserver.rb +++ b/lib/bundler/environment_preserver.rb @@ -6,7 +6,6 @@ module Bundler BUNDLER_KEYS = %w[ BUNDLE_BIN_PATH BUNDLE_GEMFILE - BUNDLER_4_MODE BUNDLER_VERSION BUNDLER_SETUP GEM_HOME diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 2267dc3ee0..34e4bcf495 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -50,6 +50,8 @@ module Bundler @major_version >= target_major_version end + attr_reader :bundler_version + def initialize(bundler_version) @bundler_version = Gem::Version.create(bundler_version) @major_version = @bundler_version.segments.first diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb index c2f54052d8..7db6c9f6f1 100644 --- a/lib/bundler/self_manager.rb +++ b/lib/bundler/self_manager.rb @@ -98,7 +98,6 @@ module Bundler def autoswitching_applies? ENV["BUNDLER_VERSION"].nil? && - ENV["BUNDLER_4_MODE"].nil? && ruby_can_restart_with_same_arguments? && lockfile_version end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 5e4fb17bfb..7a8fb214c7 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = (ENV["BUNDLER_4_MODE"] == "true" ? "4.0.0" : "2.7.0.dev").freeze + VERSION = "2.7.0.dev".freeze def self.bundler_major_version @bundler_major_version ||= gem_version.segments.first diff --git a/spec/bundler/bundler/settings_spec.rb b/spec/bundler/bundler/settings_spec.rb index 592db81e9b..c3d8533eab 100644 --- a/spec/bundler/bundler/settings_spec.rb +++ b/spec/bundler/bundler/settings_spec.rb @@ -333,7 +333,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow C expect(Bundler.ui).not_to receive(:warn) - expect(settings.all).to be_empty + expect(settings.all).to eq(simulated_version ? ["simulate_version"] : []) end it "converts older keys with dashes" do diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 1392b17315..6840e2b04a 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -453,7 +453,7 @@ E it "does not make bundler crash and ignores the configuration" do bundle "config list --parseable" - expect(out).to be_empty + expect(out).to eq(simulated_version ? "simulate_version=#{simulated_version}" : "") expect(err).to be_empty ruby(<<~RUBY) @@ -476,26 +476,38 @@ E describe "subcommands" do it "list" do bundle "config list", env: { "BUNDLE_FOO" => "bar" } - expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nfoo\nSet via BUNDLE_FOO: \"bar\"" + expected = "Settings are listed in order of priority. The top value will be used.\nfoo\nSet via BUNDLE_FOO: \"bar\"" + expected += "\n\nsimulate_version\nSet via BUNDLE_SIMULATE_VERSION: \"#{simulated_version}\"" if simulated_version + expect(out).to eq(expected) bundle "config list", env: { "BUNDLE_FOO" => "bar" }, parseable: true - expect(out).to eq "foo=bar" + expected = "foo=bar" + expected += "\nsimulate_version=#{simulated_version}" if simulated_version + expect(out).to eq(expected) end it "list with credentials" do bundle "config list", env: { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } - expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"user:[REDACTED]\"" + expected = "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"user:[REDACTED]\"" + expected += "\n\nsimulate_version\nSet via BUNDLE_SIMULATE_VERSION: \"#{simulated_version}\"" if simulated_version + expect(out).to eq(expected) bundle "config list", parseable: true, env: { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } - expect(out).to eq "gems.myserver.com=user:password" + expected = "gems.myserver.com=user:password" + expected += "\nsimulate_version=#{simulated_version}" if simulated_version + expect(out).to eq(expected) end it "list with API token credentials" do bundle "config list", env: { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } - expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"[REDACTED]:x-oauth-basic\"" + expected = "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"[REDACTED]:x-oauth-basic\"" + expected += "\n\nsimulate_version\nSet via BUNDLE_SIMULATE_VERSION: \"#{simulated_version}\"" if simulated_version + expect(out).to eq(expected) bundle "config list", parseable: true, env: { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } - expect(out).to eq "gems.myserver.com=api_token:x-oauth-basic" + expected = "gems.myserver.com=api_token:x-oauth-basic" + expected += "\nsimulate_version=#{simulated_version}" if simulated_version + expect(out).to eq(expected) end it "get" do diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 5c1ce3ca0f..e1fbe6934a 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -109,7 +109,7 @@ RSpec.describe "the lockfile format" do #{version} L - install_gemfile <<-G, verbose: true, env: { "BUNDLER_4_MODE" => nil } + install_gemfile <<-G, verbose: true source "https://gem.repo4" gem "myrack" diff --git a/spec/bundler/realworld/slow_perf_spec.rb b/spec/bundler/realworld/slow_perf_spec.rb index d9d1aef81c..5b74b9ea9e 100644 --- a/spec/bundler/realworld/slow_perf_spec.rb +++ b/spec/bundler/realworld/slow_perf_spec.rb @@ -131,14 +131,8 @@ RSpec.describe "bundle install with complex dependencies", realworld: true do end G - if Bundler.feature_flag.bundler_4_mode? - bundle "lock", env: { "DEBUG_RESOLVER" => "1" }, raise_on_error: false + bundle "lock", env: { "DEBUG_RESOLVER" => "1" } - expect(out).to include("backtracking").exactly(26).times - else - bundle "lock", env: { "DEBUG_RESOLVER" => "1" } - - expect(out).to include("Solution found after 10 attempts") - end + expect(out).to include("Solution found after 10 attempts") end end diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb index 880bdaface..2cb2d0175f 100644 --- a/spec/bundler/runtime/self_management_spec.rb +++ b/spec/bundler/runtime/self_management_spec.rb @@ -10,7 +10,7 @@ RSpec.describe "Self management" do "9.4.0" end - around do |example| + before do build_repo4 do build_bundler previous_minor @@ -26,8 +26,6 @@ RSpec.describe "Self management" do G pristine_system_gems "bundler-#{current_version}" - - with_env_vars("BUNDLER_4_MODE" => nil, &example) end it "installs locked version when using system path and uses it" do diff --git a/spec/bundler/support/env.rb b/spec/bundler/support/env.rb index 0899bd82a3..a198757f30 100644 --- a/spec/bundler/support/env.rb +++ b/spec/bundler/support/env.rb @@ -9,5 +9,9 @@ module Spec def rubylib ENV["RUBYLIB"].to_s.split(File::PATH_SEPARATOR) end + + def simulated_version + ENV["BUNDLE_SIMULATE_VERSION"] + end end end diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb index 663b7fa44b..a20b950fc7 100644 --- a/spec/bundler/support/filters.rb +++ b/spec/bundler/support/filters.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true class RequirementChecker < Proc - def self.against(present, major_only: false) - present = present.split(".")[0] if major_only - provided = Gem::Version.new(present) + def self.against(provided, major_only: false) + provided = Gem::Version.new(provided.segments.first) if major_only new do |required| requirement = Gem::Requirement.new(required) @@ -28,8 +27,8 @@ end RSpec.configure do |config| config.filter_run_excluding realworld: true - config.filter_run_excluding bundler: RequirementChecker.against(Bundler::VERSION, major_only: true) - config.filter_run_excluding rubygems: RequirementChecker.against(Gem::VERSION) + config.filter_run_excluding bundler: RequirementChecker.against(Bundler.feature_flag.bundler_version, major_only: true) + config.filter_run_excluding rubygems: RequirementChecker.against(Gem.rubygems_version) config.filter_run_excluding ruby_repo: !ENV["GEM_COMMAND"].nil? config.filter_run_excluding no_color_tty: Gem.win_platform? || !ENV["GITHUB_ACTION"].nil? config.filter_run_excluding permissions: Gem.win_platform?