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

Make entrypoint writes atomic to avoid overwriting symlinks #5165

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

charliermarsh
Copy link
Member

Summary

It turns out that if path is a symlink, File::create(path)?.write_all(content.as_ref())? will overwrite the target file. That means an entrypoint named python would actually overwrite the user's source Python executable, which is symlinked into the virtual environment.

This PR replaces that code with our atomic write method.

Closes #5152.

Test Plan

I ran through the test plan https://github.com/astral-sh/uv/issues/5152, but used an executable named bar linked to foo.txt instead...

@charliermarsh charliermarsh added the bug Something isn't working label Jul 17, 2024
@charliermarsh charliermarsh marked this pull request as ready for review July 17, 2024 19:29
@charliermarsh charliermarsh merged commit 8edfdbe into main Jul 17, 2024
52 checks passed
@charliermarsh charliermarsh deleted the charlie/atomic branch July 17, 2024 19:44
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 script install into .venv overwrites python
2 participants