summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2020-02-11 21:21:33 +0000
committerBundlerbot <bot@bundler.io>2020-02-11 21:21:33 +0000
commit838ca7241a6dd6136586d125d669e828bc969677 (patch)
tree99028f51c9f27b9835b35363da5f2e87d16d5ba7
parent0a55b739946330ddc6312f58cfb23680db0b7328 (diff)
parent2a62902a202c3fc0d576b016d28a93f0d18f955f (diff)
downloadbundler-838ca7241a6dd6136586d125d669e828bc969677.tar.gz
Merge #7622
7622: Fix config location edge case r=deivid-rodriguez a=deivid-rodriguez <!-- Thanks so much for the contribution! If you're updating documentation, make sure you run `bin/rake man:build` and squash the result into your changes, so that all documentation formats are updated. To make reviewing this PR a bit easier, please fill out answers to the following questions. --> ### What was the end-user or developer problem that led to this PR? <!-- Write a clear and complete description of the problem --> The problem was that if `BUNDLE_APP_CONFIG` is set to an absolute path, and there's no Gemfile up in the directory hierarchy, bundler would end up using the default config location instead of the customized one. ### What is your fix for the problem, implemented in this PR? My fix is to completely avoid bundler's root resolution for resolving the config path in this case, since `BUNDLE_APP_CONFIG` includes all the information we need to know. <!-- Explain the fix being implemented. Include any diagnosis you run to determine the cause of the issue and your conclusions. If you considered other alternatives, explain why you end up choosing the current implementation --> Fixes #7610. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--lib/bundler.rb8
-rw-r--r--spec/commands/config_spec.rb12
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index df345539c8..f081d4d63f 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -285,7 +285,13 @@ module Bundler
def app_config_path
if app_config = ENV["BUNDLE_APP_CONFIG"]
- Pathname.new(app_config).expand_path(root)
+ app_config_pathname = Pathname.new(app_config)
+
+ if app_config_pathname.absolute?
+ app_config_pathname
+ else
+ app_config_pathname.expand_path(root)
+ end
else
root.join(".bundle")
end
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 7a45dd0dd7..3a6b72d988 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe ".bundle/config" do
end
end
- describe "location" do
+ describe "location with a gemfile" do
before :each do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -64,6 +64,16 @@ RSpec.describe ".bundle/config" do
end
end
+ describe "location without a gemfile" do
+ it "works with an absolute path" do
+ ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
+ bundle "config set --local path vendor/bundle"
+
+ expect(bundled_app(".bundle")).not_to exist
+ expect(tmp("foo/bar/config")).to exist
+ end
+ end
+
describe "global" do
before(:each) do
install_gemfile <<-G