Skip to content

Commit

Permalink
[rubygems/rubygems] Respect BUNDLE_USER_HOME for global config loca…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Aug 31, 2021
1 parent ea16a0d commit 21db587
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/settings.rb
Expand Up @@ -430,6 +430,8 @@ def global_config_file
Pathname.new(ENV["BUNDLE_CONFIG"])
elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
Pathname.new(ENV["BUNDLE_USER_CONFIG"])
elsif ENV["BUNDLE_USER_HOME"] && !ENV["BUNDLE_USER_HOME"].empty?
Pathname.new(ENV["BUNDLE_USER_HOME"]).join("config")
elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
end
Expand Down
10 changes: 10 additions & 0 deletions spec/bundler/commands/config_spec.rb
Expand Up @@ -88,6 +88,16 @@
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

context "when not explicitly configured, but BUNDLE_USER_HOME set" do
let(:bundle_user_home) { bundled_app(".bundle").to_s }

it "uses the right location" do
bundle "config set path vendor", :env => { "BUNDLE_USER_HOME" => bundle_user_home }
bundle "config get path", :env => { "BUNDLE_USER_HOME" => bundle_user_home }
expect(out).to include("Set for the current user (#{bundle_user_home}/config): \"vendor\"")
end
end
end

describe "global" do
Expand Down

0 comments on commit 21db587

Please sign in to comment.