Skip to content

Fix uv tool upgrade after Python version upgrade#18397

Open
charliermarsh wants to merge 1 commit intomainfrom
charlie/up-tool
Open

Fix uv tool upgrade after Python version upgrade#18397
charliermarsh wants to merge 1 commit intomainfrom
charlie/up-tool

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Mar 10, 2026

Summary

If a tool references a Python environment with a Python interpreter that no longer exists, uv tool upgrade now reinstalls it. I think this is a reasonable improvement.

Note that #17907 also claims that uv tool install --force is not working; it's hard to say why that's happening without an MRE.

See: #17907.

@charliermarsh charliermarsh added the bug Something isn't working label Mar 10, 2026
@charliermarsh charliermarsh marked this pull request as ready for review March 10, 2026 19:13
@charliermarsh charliermarsh changed the title Fix uv tool upgrade after Python version upgrade Fix uv tool upgrade after Python version upgrade Mar 10, 2026
@charliermarsh charliermarsh requested a review from zanieb March 13, 2026 15:25
@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 13, 2026

Related to #18121

Comment on lines +939 to +941
let content = fs_err::read_to_string(tool_dir.join("babel").join("pyvenv.cfg")).unwrap();
let lines: Vec<&str> = content.split('\n').collect();
assert_snapshot!(lines[lines.len() - 3], @"version_info = 3.12.[X]");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty questionable? if we want to assert on that line we should extract it with a prefix match?

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 13, 2026

I'm a little unsure it should repair the environment rather than skip it and encourage use of uv tool install to recreate it. I wouldn't expect the interpreter to change during a tool version upgrade.

Why do you say "after Python version upgrade" in the title instead of "when Python interpreter is missing"?

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.

2 participants