Skip to content
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

Multiple config paths treated as single path #12903

Open
1 task done
alexreg opened this issue Aug 8, 2024 · 6 comments
Open
1 task done

Multiple config paths treated as single path #12903

alexreg opened this issue Aug 8, 2024 · 6 comments
Labels
C: configuration Configuration management and loading project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior

Comments

@alexreg
Copy link

alexreg commented Aug 8, 2024

Description

The global configuration path on my macOS system is in fact a colon-separated list of multiple paths, but is treated as a single path.

Specifically, the global configuration path /opt/homebrew/share/pip:/Library/Application Support/pip/pip.conf is incorrectly treated as a single path where the : is part of a supposed intermediate directory named pip:.

This seems to be originating with the site_data_dir function, which since v4.2.0 may return a colon-separated list of paths, and pip doesn't presently handle that.

Expected behavior

Both global configuration paths should be searched separately by pip.

pip version

24.2

Python version

3.12.4

OS

macOS 14.5

How to Reproduce

  1. On a macOS system with Homebrew, run brew install python3.12.
  2. Run pip3.12 config debug.
  3. Observe the global path output by the previous command is in fact multiple paths separated by colons (two in my case).

Output

$ pip3.12 config debug
env_var:
env:
global:
  /opt/homebrew/share/pip:/Library/Application Support/pip/pip.conf, exists: False
site:
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/pip.conf, exists: False
user:
  /Users/alex/.pip/pip.conf, exists: True
  /Users/alex/.config/pip/pip.conf, exists: False

Code of Conduct

@alexreg alexreg added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Aug 8, 2024
@ichard26 ichard26 added C: configuration Configuration management and loading and removed S: needs triage Issues/PRs that need to be triaged labels Aug 9, 2024
@ichard26
Copy link
Member

ichard26 commented Aug 9, 2024

D'oh, how silly. A PR fixing this would be welcome!

I can't find a reason why multipath was enabled, but not handled. The PR introducing it doesn't have any clues: #7501.

@pradyunsg pradyunsg added the project: vendored dependency Related to a vendored dependency label Aug 12, 2024
@pradyunsg
Copy link
Member

It looks like this needs to be fixed in platformdirs. Labelling this to reflect that. @alexreg Could I ask you to file an issue with https://github.com/platformdirs/platformdirs/?

@pradyunsg
Copy link
Member

Or... am I misunderstanding something?

@uranusjr
Copy link
Member

uranusjr commented Aug 12, 2024

It looks like this is an intended behaviour, and downstream users are simply expected to handle the possible return format.

I should note that even platformdirs itself does not handle this correctly—site_data_path for example simply treats this value as a path and would also fail.

https://github.com/platformdirs/platformdirs/blob/6a0ff603755b2b5af1f6e272054894867acfaed1/src/platformdirs/api.py#L179-L182

It seems like the Homebrew note was added last year without work to actually accomodate this change anywhere else. This change was not mentioned in the release notes.

tox-dev/platformdirs@682cdcb

So yeah from the information currently available, I think we should fix it in pip. But judging from the peripherals, we should probably still raise an issue in platformdirs first to make sure the “intended” behaviour is actually intended, and then act accordingly.

@matthewhughes934
Copy link
Contributor

I created an issue upstream to discuss: tox-dev/platformdirs#292

@alexreg
Copy link
Author

alexreg commented Aug 16, 2024

I agree with @uranusjr that this appears to be an issue with both pip and platformdirs itself failing to handle the case of multiple colon-separated paths. I'll have a look at implementing a fix and submitting a PR on the weekend, if no one beats me to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration Configuration management and loading project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants