Skip to content

Comments

use $TMPDIR/uv-locks instead of putting lockfiles directly in $TMPDIR#14225

Closed
oconnor663 wants to merge 1 commit intojack/lock_wheel_buildsfrom
jack/uv_lock_dir
Closed

use $TMPDIR/uv-locks instead of putting lockfiles directly in $TMPDIR#14225
oconnor663 wants to merge 1 commit intojack/lock_wheel_buildsfrom
jack/uv_lock_dir

Conversation

@oconnor663
Copy link
Contributor

@oconnor663 oconnor663 commented Jun 23, 2025

As @zanieb has pointed out in chat, moving file locks around makes us vulnerable to races between different versions of uv that don't agree on the file lock path. I'm comfortable ignoring that as rare enough not to matter, but I'm curious what other folks think.

Atomically creating a directory with universal write permissions also turned out to be surprisingly complicated, requiring us to spawn a shell command that first sets umask. My instinct is that this command will be portable to all flavors of Unix, but if we'd rather skip shelling out and tolerate the extremely brief mkdir-then-chmod race, that could also make sense. Feedback needed.

This PR sits on top of #14174.

@oconnor663
Copy link
Contributor Author

I'm closing this for now. Ad-hoc proxy file locking is done in a lot of different ways, e.g.:

pub(crate) async fn lock(script: Pep723ItemRef<'_>) -> Result<LockedFile, std::io::Error> {
match script {
Pep723ItemRef::Script(script) => {
LockedFile::acquire(
std::env::temp_dir().join(format!("uv-{}.lock", cache_digest(&script.path))),
script.path.simplified_display(),
)
.await
}
Pep723ItemRef::Remote(.., url) => {
LockedFile::acquire(
std::env::temp_dir().join(format!("uv-{}.lock", cache_digest(url))),
url.to_string(),
)
.await
}
Pep723ItemRef::Stdin(metadata) => {
LockedFile::acquire(
std::env::temp_dir().join(format!("uv-{}.lock", cache_digest(&metadata.raw))),
"stdin".to_string(),
)
.await
}
}
}
}

It might be nice to refactor that (and interpreter.rs and others) to use a common abstraction, but playing with that made it clear that it's going to grow the scope of #14174 more than I'd prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant