summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-05-30 20:25:29 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-05-30 21:50:07 +0900
commit4bbeed61346d6016e2d72818e8068bedcb9f006d (patch)
treeddf1b23eb0e63a47efa8cc1fc0b72652e3dac354
parent30b960ba345fd462f98db204f47bba66819d9884 (diff)
Merge RubyGems/Bundler master from 4076391fce5847689bf2ec402b17133fe4e32285
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7873
-rw-r--r--lib/bundler.rb7
-rw-r--r--lib/bundler/definition.rb9
-rw-r--r--lib/bundler/installer.rb2
-rw-r--r--lib/bundler/lockfile_parser.rb1
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--spec/bundler/commands/update_spec.rb35
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb2
-rw-r--r--spec/bundler/lock/git_spec.rb2
-rw-r--r--spec/bundler/support/helpers.rb2
-rw-r--r--spec/bundler/support/path.rb3
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb4
-rw-r--r--test/rubygems/test_gem_gem_runner.rb5
-rw-r--r--tool/bundler/dev_gems.rb3
-rw-r--r--tool/bundler/dev_gems.rb.lock33
-rw-r--r--tool/bundler/rubocop_gems.rb.lock6
-rw-r--r--tool/bundler/standard_gems.rb.lock6
17 files changed, 78 insertions, 46 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 69370e81a7..f83268e9cd 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -210,9 +210,10 @@ module Bundler
end
def frozen_bundle?
- frozen = settings[:deployment]
- frozen ||= settings[:frozen]
- frozen
+ frozen = settings[:frozen]
+ return frozen unless frozen.nil?
+
+ settings[:deployment]
end
def locked_gems
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 3249fb09dc..1444cc2b0a 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -361,10 +361,8 @@ module Bundler
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
unless explicit_flag
- suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
- "bundle config unset frozen"
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
- "bundle config unset deployment"
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
+ "bundle config set frozen false"
end
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
"freeze \nby running `#{suggested_command}`." if suggested_command
@@ -886,7 +884,8 @@ module Bundler
if preserve_unknown_sections
sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
+ sections_to_ignore << LockfileParser::RUBY
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
whitespace_cleanup = /\n{2,}/
current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 680e812ac8..59b6a6ad22 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -90,7 +90,7 @@ module Bundler
Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
- lock unless Bundler.frozen_bundle?
+ lock
Standalone.new(options[:standalone], @definition).generate if options[:standalone]
end
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 97cbf211ba..7360a36752 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -26,6 +26,7 @@ module Bundler
KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
def self.sections_in_lockfile(lockfile_contents)
lockfile_contents.scan(/^\w[\w ]*$/).uniq
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index c2b681c60d..c35d0f5ccc 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -245,7 +245,7 @@ By default, this RubyGems will install gem as:
def install_executables(bin_dir)
prog_mode = options[:prog_mode] || 0o755
- executables = { "gem" => "bin" }
+ executables = { "gem" => "exe" }
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 7016c3e19f..7a0d435860 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -659,21 +659,21 @@ RSpec.describe "bundle update" do
expect(last_command).to be_failure
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
- expect(err).to match(/freeze \nby running `bundle config unset deployment`./m)
+ expect(err).to match(/freeze \nby running `bundle config set frozen false`./m)
end
- it "should suggest different command when frozen is set globally", :bundler => "< 3" do
+ it "should fail loudly when frozen is set globally" do
bundle "config set --global frozen 1"
bundle "update", :all => true, :raise_on_error => false
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config unset frozen`./m)
+ and match(/freeze \nby running `bundle config set frozen false`./m)
end
- it "should suggest different command when frozen is set globally", :bundler => "3" do
+ it "should fail loudly when deployment is set globally" do
bundle "config set --global deployment true"
bundle "update", :all => true, :raise_on_error => false
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config unset deployment`./m)
+ and match(/freeze \nby running `bundle config set frozen false`./m)
end
it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
@@ -1451,6 +1451,31 @@ RSpec.describe "bundle update --bundler" do
expect(out).to include("Using bundler 2.3.9")
end
end
+
+ it "prints an error when trying to update bundler in frozen mode" do
+ system_gems "bundler-2.3.9"
+
+ gemfile <<~G
+ source "#{file_uri_for(gem_repo2)}"
+ G
+
+ lockfile <<-L
+ GEM
+ remote: #{file_uri_for(gem_repo2)}/
+ specs:
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ 2.1.4
+ L
+
+ bundle "update --bundler=2.3.9", :env => { "BUNDLE_FROZEN" => "true" }
+ expect(err).to include("Cannot write a changed lockfile while frozen")
+ end
end
# these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that.
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index e3be680d89..c96a78bc1c 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -1148,7 +1148,7 @@ RSpec.describe "bundle install with git sources" do
it "gives a helpful error message when the remote branch no longer exists" do
build_git "foo"
- install_gemfile <<-G, :raise_on_error => false
+ install_gemfile <<-G, :env => { "LANG" => "en" }, :raise_on_error => false
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :branch => "deadbeef"
G
diff --git a/spec/bundler/lock/git_spec.rb b/spec/bundler/lock/git_spec.rb
index 1c1f6fa93d..ac3d10223c 100644
--- a/spec/bundler/lock/git_spec.rb
+++ b/spec/bundler/lock/git_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe "bundle lock with git gems" do
gem 'foo', :git => "#{lib_path("foo-1.0")}", :branch => "bad"
G
- bundle "lock --update foo", :raise_on_error => false
+ bundle "lock --update foo", :env => { "LANG" => "en" }, :raise_on_error => false
expect(err).to include("Revision bad does not exist in the repository")
end
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 9bfa1458c6..7b8c56b6ad 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -302,7 +302,7 @@ module Spec
def install_gem(path, default = false)
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- args = "--no-document --ignore-dependencies"
+ args = "--no-document --ignore-dependencies --verbose --local"
args += " --default --install-dir #{system_gem_path}" if default
gem_command "install #{args} '#{path}'"
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 2870a8b678..5c156c47cf 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -42,7 +42,8 @@ module Spec
end
def dev_gemfile
- @dev_gemfile ||= tool_dir.join("dev_gems.rb")
+ name = RUBY_VERSION.start_with?("2.6") ? "dev26_gems.rb" : "dev_gems.rb"
+ @dev_gemfile ||= tool_dir.join(name)
end
def bindir
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index cd94f61247..6859d7a5cb 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -18,7 +18,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.options[:document] = []
filelist = %w[
- bin/gem
+ exe/gem
lib/rubygems.rb
lib/rubygems/requirement.rb
lib/rubygems/ssl_certs/rubygems.org/foo.pem
diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb
index ed2290463f..0d893f5424 100644
--- a/test/rubygems/test_gem_ext_cargo_builder.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder.rb
@@ -100,7 +100,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
require "tmpdir"
env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
- gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../bin/gem", __dir__)]
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../exe/gem", __dir__)]
Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
@@ -122,7 +122,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
require "tmpdir"
env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
- gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../bin/gem", __dir__)]
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../exe/gem", __dir__)]
Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb
index 3257c4bd72..5a3f5fe9f4 100644
--- a/test/rubygems/test_gem_gem_runner.rb
+++ b/test/rubygems/test_gem_gem_runner.rb
@@ -4,9 +4,6 @@ require_relative "helper"
class TestGemGemRunner < Gem::TestCase
def setup
- @orig_gem_home = ENV["GEM_HOME"]
- ENV["GEM_HOME"] = @gemhome
-
require "rubygems/command"
@orig_args = Gem::Command.build_args
@orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup
@@ -24,8 +21,6 @@ class TestGemGemRunner < Gem::TestCase
Gem::Command.build_args = @orig_args
Gem::Command.specific_extra_args_hash = @orig_specific_extra_args
Gem::Command.extra_args = @orig_extra_args
-
- ENV["GEM_HOME"] = @orig_gem_home
end
def test_do_configuration
diff --git a/tool/bundler/dev_gems.rb b/tool/bundler/dev_gems.rb
index ef63263414..856256a246 100644
--- a/tool/bundler/dev_gems.rb
+++ b/tool/bundler/dev_gems.rb
@@ -7,7 +7,8 @@ gem "rake", "~> 13.0"
gem "rb_sys"
gem "webrick", "~> 1.6"
-gem "parallel_tests", "~> 2.29"
+gem "turbo_tests", "~> 2.1"
+gem "parallel_tests", "< 3.9.0"
gem "parallel", "~> 1.19"
gem "rspec-core", "~> 3.12"
gem "rspec-expectations", "~> 3.12"
diff --git a/tool/bundler/dev_gems.rb.lock b/tool/bundler/dev_gems.rb.lock
index 43eb7c9960..c7c323ea54 100644
--- a/tool/bundler/dev_gems.rb.lock
+++ b/tool/bundler/dev_gems.rb.lock
@@ -5,34 +5,42 @@ GEM
hpricot (0.8.6)
hpricot (0.8.6-java)
mustache (1.1.1)
- parallel (1.22.1)
- parallel_tests (2.32.0)
+ parallel (1.23.0)
+ parallel_tests (3.8.1)
parallel
- power_assert (2.0.2)
+ power_assert (2.0.3)
rake (13.0.6)
- rb_sys (0.9.63)
+ rb_sys (0.9.78)
rdiscount (2.2.7)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
- rspec-core (3.12.0)
+ rspec (3.12.0)
+ rspec-core (~> 3.12.0)
+ rspec-expectations (~> 3.12.0)
+ rspec-mocks (~> 3.12.0)
+ rspec-core (3.12.2)
rspec-support (~> 3.12.0)
- rspec-expectations (3.12.0)
+ rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
- rspec-mocks (3.12.1)
+ rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
- test-unit (3.5.5)
+ test-unit (3.5.9)
power_assert
- uri (0.12.0)
- webrick (1.7.0)
+ turbo_tests (2.1.0)
+ bundler (>= 2.1)
+ parallel_tests (>= 3.3.0, < 5)
+ rspec (>= 3.10)
+ uri (0.12.1)
+ webrick (1.8.1)
PLATFORMS
+ arm64-darwin-22
java
- ruby
universal-java-11
universal-java-18
x64-mingw-ucrt
@@ -42,7 +50,7 @@ PLATFORMS
DEPENDENCIES
parallel (~> 1.19)
- parallel_tests (~> 2.29)
+ parallel_tests (< 3.9.0)
rake (~> 13.0)
rb_sys
ronn (~> 0.7.3)
@@ -50,6 +58,7 @@ DEPENDENCIES
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
test-unit (~> 3.0)
+ turbo_tests (~> 2.1)
uri (~> 0.12.0)
webrick (~> 1.6)
diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock
index 04d49cf0de..7f43e38dcb 100644
--- a/tool/bundler/rubocop_gems.rb.lock
+++ b/tool/bundler/rubocop_gems.rb.lock
@@ -21,12 +21,12 @@ GEM
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
- rspec-core (3.12.0)
+ rspec-core (3.12.2)
rspec-support (~> 3.12.0)
- rspec-expectations (3.12.0)
+ rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
- rspec-mocks (3.12.1)
+ rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock
index 6cb9d7efd9..d0387b438c 100644
--- a/tool/bundler/standard_gems.rb.lock
+++ b/tool/bundler/standard_gems.rb.lock
@@ -22,12 +22,12 @@ GEM
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
- rspec-core (3.12.0)
+ rspec-core (3.12.2)
rspec-support (~> 3.12.0)
- rspec-expectations (3.12.0)
+ rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
- rspec-mocks (3.12.1)
+ rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)