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

Fix interpreter cache collisions for relative virtualenv paths #3823

Merged
merged 1 commit into from
May 24, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented May 24, 2024

Closes #3784

The cache did not use an absolute path. I'm not sure this is actually a new bug, as this code wasn't touched in #3266 but perhaps there was a slight difference in the paths we were passing around. Note, just canonicalizing the path as soon as we see it doesn't work because then we jump out of the virtual environmnent into the system interpreter.

Test plan

❯ uv venv
Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
❯ uv pip install anyio
Resolved 3 packages in 81ms
Installed 3 packages in 4ms
 + anyio==4.3.0
 + idna==3.7
 + sniffio==1.3.1
❯ mkdir uv-issue-3784 && cd uv-issue-3784
❯ uv venv
Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

❯ gcm
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
❯ cargo run -q -- pip list -v -p .venv
DEBUG Checking for Python interpreter in directory `.venv`
TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
Package Version
------- -------
anyio   4.3.0
idna    3.7
sniffio 1.3.1
❯ cd uv-issue-3784
❯ cargo run -q -- pip list -v -p .venv
DEBUG Checking for Python interpreter in directory `.venv`
TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3
DEBUG Using Python 3.12.3 environment at /Users/zb/workspace/uv/.venv/bin/python3
Package Version
------- -------
anyio   4.3.0
idna    3.7
sniffio 1.3.1

❯ cd ..
❯ gco zb/fix-relative-venv
Switched to branch 'zb/fix-relative-venv'
❯ cargo run -q -- pip list -v -p .venv
DEBUG Checking for Python interpreter in directory `.venv`
TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
Package Version
------- -------
anyio   4.3.0
idna    3.7
sniffio 1.3.1
❯ cd uv-issue-3784
❯ cargo run -q -- pip list -v -p .venv
DEBUG Checking for Python interpreter in directory `.venv`
TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3
DEBUG Using Python 3.12.3 environment at .venv/bin/python3

@zanieb zanieb added the bug Something isn't working label May 24, 2024
@zanieb zanieb force-pushed the zb/fix-relative-venv branch from 127480a to 196dfa5 Compare May 24, 2024 14:58
@zanieb zanieb merged commit 674d167 into main May 24, 2024
46 checks passed
@zanieb zanieb deleted the zb/fix-relative-venv branch May 24, 2024 16:18
@ydshieh
Copy link

ydshieh commented May 27, 2024

Hi

Should we still apply the suggestion mentioned

#3784 (comment)

We still get the same issue with 0.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv pip venv discovery broken for some relative paths
3 participants