This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6318 - jhawthorn:fix_incorrect_test_in_requires_sudo, …
…r=segiddins Check correct paths are writable in requires_sudo? ### What was the end-user problem that led to this PR? Bundler was attempting to use `sudo`, despite having permissions to create `bundle_path` (which didn't yet exist). For some reason this became an issue in recent versions of bundler, where it wasn't one before. I'm not sure what change caused this problem to be exposed since `requires_sudo?` has not changed in a while. ### What was your diagnosis of the problem? `requires_sudo?` checks 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. Unfortunately, when these two rules were applied together, we got the wrong result. 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. ### What is your fix for the problem, implemented in this PR? This commit fixes the issue by always checking the writability of `$bundle_path/*` instead of `$parent_path/*`. ### Why did you choose this fix out of the possible options? If we are able to create `bundle_path`, we know that we can write to anything within it. Changing the test to use `Dir["$bundle_path/*"]` is a succinct way to implement this since it will return `[]` if `bundle_path` does not yet exist.
- Loading branch information