Skip to content

Commit

Permalink
Merge RubyGems/Bundler master from 4076391fce5847689bf2ec402b17133fe4…
Browse files Browse the repository at this point in the history
…e32285
  • Loading branch information
hsbt committed May 30, 2023
1 parent 30b960b commit 4bbeed6
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 46 deletions.
7 changes: 4 additions & 3 deletions lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ def definition(unlock = nil)
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
Expand Down
9 changes: 4 additions & 5 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,8 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
"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
Expand Down Expand Up @@ -886,7 +884,8 @@ def lockfiles_equal?(current, proposed, preserve_unknown_sections)
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
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run(options)

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
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/lockfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LockfileParser
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
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def execute
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

Expand Down
35 changes: 30 additions & 5 deletions spec/bundler/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -659,21 +659,21 @@

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
Expand Down Expand Up @@ -1451,6 +1451,31 @@
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.
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/lock/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def system_gems(*gems)
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}'"
Expand Down
3 changes: 2 additions & 1 deletion spec/bundler/support/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def standard_gemfile
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
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_commands_setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup
@cmd.options[:document] = []

filelist = %w[
bin/gem
exe/gem
lib/rubygems.rb
lib/rubygems/requirement.rb
lib/rubygems/ssl_certs/rubygems.org/foo.pem
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_gem_ext_cargo_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_full_integration
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"))
Expand All @@ -122,7 +122,7 @@ def test_custom_name
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"))
Expand Down
5 changes: 0 additions & 5 deletions test/rubygems/test_gem_gem_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

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
Expand All @@ -24,8 +21,6 @@ def teardown
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
Expand Down
3 changes: 2 additions & 1 deletion tool/bundler/dev_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
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"
Expand Down
33 changes: 21 additions & 12 deletions tool/bundler/dev_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,14 +50,15 @@ PLATFORMS

DEPENDENCIES
parallel (~> 1.19)
parallel_tests (~> 2.29)
parallel_tests (< 3.9.0)
rake (~> 13.0)
rb_sys
ronn (~> 0.7.3)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
test-unit (~> 3.0)
turbo_tests (~> 2.1)
uri (~> 0.12.0)
webrick (~> 1.6)

Expand Down
6 changes: 3 additions & 3 deletions tool/bundler/rubocop_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tool/bundler/standard_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4bbeed6

Please sign in to comment.