summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-07-30 10:30:24 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-08-31 19:06:14 +0900
commit0ab160e2e0b959054c28b06f1ada3f015c9f3bc3 (patch)
tree20e022066ec64e4012996cbc4dfaf08254d857f9
parentd37c2441ccd7dcdcedc317065c0f8141f9a66714 (diff)
downloadruby-0ab160e2e0b959054c28b06f1ada3f015c9f3bc3.tar.gz
[rubygems/rubygems] Respect `BUNDLE_USER_CONFIG` if set
https://github.com/rubygems/rubygems/commit/f28ab141af
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--spec/bundler/commands/config_spec.rb14
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index de42cc16af..03126f616c 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -428,6 +428,8 @@ module Bundler
def global_config_file
if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
Pathname.new(ENV["BUNDLE_CONFIG"])
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
+ Pathname.new(ENV["BUNDLE_USER_CONFIG"])
elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
end
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
index 1ef84c8195..4e13a7903e 100644
--- a/spec/bundler/commands/config_spec.rb
+++ b/spec/bundler/commands/config_spec.rb
@@ -76,6 +76,20 @@ RSpec.describe ".bundle/config" do
end
end
+ describe "config location" do
+ let(:bundle_user_config) { File.join(Dir.home, ".config/bundler") }
+
+ before do
+ Dir.mkdir File.dirname(bundle_user_config)
+ end
+
+ it "can be configured through BUNDLE_USER_CONFIG" do
+ bundle "config set path vendor", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config }
+ bundle "config get path", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config }
+ expect(out).to include("Set for the current user (#{bundle_user_config}): \"vendor\"")
+ end
+ end
+
describe "global" do
before(:each) do
install_gemfile <<-G