summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/environment_preserver.rb1
-rw-r--r--lib/bundler/self_manager.rb1
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--spec/bundler/commands/update_spec.rb2
-rw-r--r--spec/bundler/lock/lockfile_spec.rb2
-rw-r--r--spec/bundler/runtime/self_management_spec.rb4
-rw-r--r--spec/bundler/support/path.rb2
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb9
8 files changed, 10 insertions, 13 deletions
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
index 444ab6fd37..5e9a44ab5d 100644
--- a/lib/bundler/environment_preserver.rb
+++ b/lib/bundler/environment_preserver.rb
@@ -6,6 +6,7 @@ module Bundler
BUNDLER_KEYS = %w[
BUNDLE_BIN_PATH
BUNDLE_GEMFILE
+ BUNDLER_3_MODE
BUNDLER_VERSION
BUNDLER_SETUP
GEM_HOME
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 72bcb264ab..0ee111f23e 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -105,6 +105,7 @@ module Bundler
def autoswitching_applies?
ENV["BUNDLER_VERSION"].nil? &&
+ ENV["BUNDLER_3_MODE"].nil? &&
ruby_can_restart_with_same_arguments? &&
lockfile_version
end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index fa24b4966e..8ac9588fb7 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.7.0.dev".freeze
+ VERSION = (ENV["BUNDLER_3_MODE"] == "true" ? "3.0.0" : "2.7.0.dev").freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index e3624ca04d..d9cb7e1e67 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -1558,7 +1558,7 @@ RSpec.describe "bundle update --bundler" do
G
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.99.9")
- bundle :update, bundler: true, verbose: true, preserve_ruby_flags: true
+ bundle :update, bundler: true, verbose: true, preserve_ruby_flags: true, env: { "BUNDLER_3_MODE" => nil }
expect(out).to include("Updating bundler to 999.0.0")
expect(out).to include("Running `bundle update --bundler \"> 0.a\" --verbose` with bundler 999.0.0")
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index 6e3232d3de..a23784ce5e 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, preserve_ruby_flags: true
+ install_gemfile <<-G, verbose: true, preserve_ruby_flags: true, env: { "BUNDLER_3_MODE" => nil }
source "https://gem.repo4"
gem "myrack"
diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb
index a481ae3a4d..bebaf4e781 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
- before do
+ around do |example|
build_repo4 do
build_bundler previous_minor
@@ -26,6 +26,8 @@ RSpec.describe "Self management" do
G
pristine_system_gems "bundler-#{current_version}"
+
+ with_env_vars("BUNDLER_3_MODE" => nil, &example)
end
it "installs locked version when using system path and uses it" do
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index b08a68f111..e8eb71d73a 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -265,7 +265,7 @@ module Spec
def replace_version_file(version, dir: source_root)
version_file = File.expand_path("lib/bundler/version.rb", dir)
contents = File.read(version_file)
- contents.sub!(/(^\s+VERSION\s*=\s*)"#{Gem::Version::VERSION_PATTERN}"/, %(\\1"#{version}"))
+ contents.sub!(/(^\s+VERSION\s*=\s*).*$/, %(\\1"#{version}"))
File.open(version_file, "w") {|f| f << contents }
end
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 7105c1ccec..dfd951268d 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -4,13 +4,6 @@ require_relative "helper"
require "rubygems/commands/setup_command"
class TestGemCommandsSetupCommand < Gem::TestCase
- bundler_gemspec = File.expand_path("../../bundler/lib/bundler/version.rb", __dir__)
- if File.exist?(bundler_gemspec)
- BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
- else
- BUNDLER_VERS = "2.0.1"
- end
-
def setup
super
@@ -35,7 +28,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
create_dummy_files(filelist)
- gemspec = util_spec "bundler", BUNDLER_VERS do |s|
+ gemspec = util_spec "bundler", "9.9.9" do |s|
s.bindir = "exe"
s.executables = ["bundle", "bundler"]
end