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

Warn when .python-version conflicts with uv venv -p <version> in projects #8847

Open
tleonhardt opened this issue Nov 5, 2024 · 5 comments
Assignees
Labels
error messages Messaging when something goes wrong

Comments

@tleonhardt
Copy link

Summary

I ask uv to install a Python 3.12 virtual environment and then ask it to run a command using what I assume is the default virtual environment and it actually runs it using Python 3.13.

Perhaps I am misunderstanding how uv is supposed to work but this is a very non-intuitive customer experience.

How to reproduce

$ uv venv --python 3.12
Using CPython 3.12.6
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
$ uv run python -V
Using CPython 3.13.0
Removed virtual environment at: .venv
Creating virtual environment at: .venv
...

Platform details

$  uv --version
uv 0.4.30 (Homebrew 2024-11-05)
  • OS: macOS Sequoia 15.1 (Apple Silicon)
@charliermarsh
Copy link
Member

Do you have a .python-version file in the directory that pins to 3.13, maybe?

@tleonhardt
Copy link
Author

Doh! I do have a .python-version file in that directory pinned to 3.13. I'm not sure where it came from.

I removed it and now it works as expected.

@charliermarsh You are the best. Your response time is truly insane. Thank you sir!

@charliermarsh
Copy link
Member

Really glad I could help! (I wonder if we should've warned in the first uv venv invocation? \cc @zanieb)

@tleonhardt
Copy link
Author

I view this as 100% my own fault.

But if you could warn users to let them know about this potentially unanticipated behavior, that would be fantastic.

@zanieb
Copy link
Member

zanieb commented Nov 5, 2024

Thanks for the ping, yeah it seems like we should probably warn there if you're changing to virtual environment to something we won't use in future project invocations.

uv run should also say where it sourced that version from. I might have made that easier in #6370.

@zanieb zanieb added the error messages Messaging when something goes wrong label Nov 5, 2024
@zanieb zanieb self-assigned this Nov 5, 2024
@zanieb zanieb reopened this Nov 5, 2024
@zanieb zanieb changed the title [Bug?] uv venv --python 3.12 creates a Python 3.13.0 virtual environment Warn when .python-version conflicts with uv venv -p <version> in projects Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

No branches or pull requests

3 participants