mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/rubygems] Make BUNDLE_LOCKFILE environment variable have precedence over lockfile method in Gemfile
It would be simpler to do `options[:lockfile] ||= ENV["BUNDLE_LOCKFILE"]`, but that doesn't work as `options` is frozen. Fixes https://github.com/ruby/rubygems/pull/9117 https://github.com/ruby/rubygems/commit/6e3603a0e9
This commit is contained in:
parent
0e22108d60
commit
456ba321a8
@ -69,7 +69,7 @@ module Bundler
|
||||
|
||||
# lock --lockfile works differently than install --lockfile
|
||||
unless current_cmd == "lock"
|
||||
custom_lockfile = options[:lockfile] || Bundler.settings[:lockfile]
|
||||
custom_lockfile = options[:lockfile] || ENV["BUNDLE_LOCKFILE"] || Bundler.settings[:lockfile]
|
||||
if custom_lockfile && !custom_lockfile.empty?
|
||||
Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", File.expand_path(custom_lockfile)
|
||||
reset_settings = true
|
||||
@ -282,8 +282,10 @@ module Bundler
|
||||
end
|
||||
|
||||
require_relative "cli/install"
|
||||
options = self.options.dup
|
||||
options["lockfile"] ||= ENV["BUNDLE_LOCKFILE"]
|
||||
Bundler.settings.temporary(no_install: false) do
|
||||
Install.new(options.dup).run
|
||||
Install.new(options).run
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -494,9 +494,9 @@ The \fBbundle install\fR \fB\-\-no\-lock\fR option (which disables lockfile crea
|
||||
.IP "2." 4
|
||||
The \fBbundle install\fR \fB\-\-lockfile\fR option\.
|
||||
.IP "3." 4
|
||||
The \fBlockfile\fR method in the Gemfile\.
|
||||
.IP "4." 4
|
||||
The \fBBUNDLE_LOCKFILE\fR environment variable\.
|
||||
.IP "4." 4
|
||||
The \fBlockfile\fR method in the Gemfile\.
|
||||
.IP "5." 4
|
||||
The default behavior of adding \fB\.lock\fR to the end of the Gemfile name\.
|
||||
.IP "" 0
|
||||
|
||||
@ -581,6 +581,6 @@ following precedence is used:
|
||||
|
||||
1. The `bundle install` `--no-lock` option (which disables lockfile creation).
|
||||
1. The `bundle install` `--lockfile` option.
|
||||
1. The `lockfile` method in the Gemfile.
|
||||
1. The `BUNDLE_LOCKFILE` environment variable.
|
||||
1. The `lockfile` method in the Gemfile.
|
||||
1. The default behavior of adding `.lock` to the end of the Gemfile name.
|
||||
|
||||
@ -41,6 +41,20 @@ RSpec.describe "bundle install with gem sources" do
|
||||
expect(bundled_app("OmgFile.lock")).to exist
|
||||
end
|
||||
|
||||
it "creates lockfile using BUNDLE_LOCKFILE instead of lockfile method" do
|
||||
ENV["BUNDLE_LOCKFILE"] = "ReallyOmgFile.lock"
|
||||
install_gemfile <<-G
|
||||
lockfile "OmgFile.lock"
|
||||
source "https://gem.repo1"
|
||||
gem "myrack", "1.0"
|
||||
G
|
||||
|
||||
expect(bundled_app("ReallyOmgFile.lock")).to exist
|
||||
expect(bundled_app("OmgFile.lock")).not_to exist
|
||||
ensure
|
||||
ENV.delete("BUNDLE_LOCKFILE")
|
||||
end
|
||||
|
||||
it "creates lockfile based on --lockfile option is given" do
|
||||
gemfile bundled_app("OmgFile"), <<-G
|
||||
source "https://gem.repo1"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user