summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2018-03-01 14:08:32 -0800
committerJohn Hawthorn <john@hawthorn.email>2018-04-20 11:33:30 -0700
commitd8bb345bd82a76fc42f819fbebc001589f53353d (patch)
tree4e6b5c82ad44e25fba62bf89cf00ce2d724d6400
parent8cc446c0f6bce6be695ce396f59f918c73255553 (diff)
downloadbundler-d8bb345bd82a76fc42f819fbebc001589f53353d.tar.gz
Check correct paths are writable in requires_sudo?
This method's goal is to check that bundle_path, and directories that bundler may need to write within it are writable. If bundle_path itself does not exist, we instead find the nearest existent parent directory, and check that that exists. However these two rules were combined incorrectly. If bundle_path did not exist, bundler would check that the nearest parent directory _and everything within that parent directory_ were writable. This could lead to false positives for requires_sudo? when bundle_path did not yet exist. This commit fixes the issue by always checking the writability of $bundle_path/* instead of $parent_path/*.
-rw-r--r--lib/bundler.rb2
-rw-r--r--spec/bundler/bundler_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 9056c1aa42..9944ebd051 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -365,7 +365,7 @@ EOF
bin_dir = bin_dir.parent until bin_dir.exist?
# if any directory is not writable, we need sudo
- files = [path, bin_dir] | Dir[path.join("build_info/*").to_s] | Dir[path.join("*").to_s]
+ files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
sudo_needed = files.any? {|f| !File.writable?(f) }
end
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 6705b9de77..131146119e 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -264,7 +264,7 @@ EOF
it { should be true }
end
- context "with unwritable files in a parent dir", pending: true do
+ context "with unwritable files in a parent dir" do
# Regression test for https://github.com/bundler/bundler/pull/6316
# It doesn't matter if there are other unwritable files so long as
# bundle_path can be created