[rubygems/rubygems] Fix path vs deployment precedence when path set through ENV

The `deployment` setting sets `path` to `vendor/bundle` implicitly, but
that should only apply if `path` is not set explicitly, at any level.

https://github.com/rubygems/rubygems/commit/3552c064c1
This commit is contained in:
David Rodríguez 2023-05-26 21:56:17 +02:00 committed by Hiroshi SHIBATA
parent 7b317243ad
commit 03246719cc
2 changed files with 9 additions and 2 deletions

View File

@ -219,7 +219,6 @@ module Bundler
def path
configs.each do |_level, settings|
path = value_for("path", settings)
path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
path_system = value_for("path.system", settings)
disabled_shared_gems = value_for("disable_shared_gems", settings)
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@ -227,7 +226,9 @@ module Bundler
return Path.new(path, system_path)
end
Path.new(nil, false)
path = "vendor/bundle" if self[:deployment]
Path.new(path, false)
end
Path = Struct.new(:explicit_path, :system_path) do

View File

@ -248,6 +248,12 @@ RSpec.describe "install in deployment or frozen mode" do
expect(out).to include("vendor/bundle2")
end
it "installs gems to custom path if specified, even when configured through ENV" do
bundle "config set deployment true"
bundle "install", :env => { "BUNDLE_PATH" => "vendor/bundle2" }
expect(out).to include("vendor/bundle2")
end
it "works with the `frozen` setting" do
bundle "config set frozen true"
bundle "install"