-
Notifications
You must be signed in to change notification settings - Fork 3.1k
appdirs: return paths relative to effective user's homedir #5360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6acf7cd
to
81020d6
Compare
Since `expanduser()` is used to expand the `~` to the home directory, `~/.cache` will always return the home directory of the user under which the python process is running. However, if pip is executed from within a Python process in which the euid has changed, this means that the cache dir (and other paths) will not be writable, causing pip to fail. This commit fixes that issue by attempting to get the username matching the euid, and using that username (e.g. `~user/.cache`) when invoking `expanduser()`.
81020d6
to
1915d8b
Compare
Unit test failures are clearly related, I'll take a look on Thursday or Friday. |
Note: there are 2 copies of appdirs: |
Ahh, thanks for catching (this is what I get when I don't read the docstring!). I can resubmit upstream. |
Submitted upstream as ActiveState/appdirs#105 |
I'm also not sure this is a bug and not normal behavior if |
Closing this PR since the fix has to happen upstream and this hasn't been shown to be significant and/or urgent enough that pip carries a patch for it. |
I agree, it's not terribly urgent. It's true that one can pass a |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When executing a pip install from within a Python process in which the euid has been changed, the appdirs helpers which use
expanduser()
return paths relative to the home directory of the actual user, rather than the effective user. This causes the install to fail when the effective user cannot write to the cachedir:With this bugfix, the installation proceeds as expected, and the sources/wheels are downloaded to the effective user's cachedir:
With regard to testing, I'm not certain how this would work with the existing setup, as the code appears to just be patching function calls, and in the absence of something like a MagicMock where you can do more complicated patching, I'm unsure how we'd confirm that we're pulling from the effective user's environment. I would welcome any guidance offered in this respect.
Resolves #5359.