Skip to content

Commit

Permalink
[rubygems/rubygems] Respect BUNDLE_USER_CONFIG if set
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 d37c244 commit 0ab160e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/settings.rb
Expand Up @@ -428,6 +428,8 @@ def printable_value(value, key)
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
Expand Down
14 changes: 14 additions & 0 deletions spec/bundler/commands/config_spec.rb
Expand Up @@ -76,6 +76,20 @@
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
Expand Down

0 comments on commit 0ab160e

Please sign in to comment.