diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index f2492e2de..baf029231 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use fs2::FileExt; use fs_err as fs; use tempfile::NamedTempFile; -use tracing::{debug, error, warn}; +use tracing::{debug, error, trace, warn}; use uv_warnings::warn_user; @@ -289,9 +289,12 @@ pub struct LockedFile(fs_err::File); impl LockedFile { pub fn acquire(path: impl AsRef, resource: impl Display) -> Result { let file = fs_err::File::create(path.as_ref())?; - debug!("Trying to lock if free: {}", path.as_ref().user_display()); + trace!("Checking lock for `{resource}`"); match file.file().try_lock_exclusive() { - Ok(()) => Ok(Self(file)), + Ok(()) => { + debug!("Acquired lock for `{resource}`"); + Ok(Self(file)) + } Err(err) => { // Log error code and enum kind to help debugging more exotic failures debug!("Try lock error, waiting for exclusive lock: {:?}", err); diff --git a/crates/uv-interpreter/src/environment.rs b/crates/uv-interpreter/src/environment.rs index 51345d0eb..ae0290e00 100644 --- a/crates/uv-interpreter/src/environment.rs +++ b/crates/uv-interpreter/src/environment.rs @@ -200,18 +200,15 @@ impl PythonEnvironment { pub fn lock(&self) -> Result { if let Some(target) = self.0.interpreter.target() { // If we're installing into a `--target`, use a target-specific lock file. - LockedFile::acquire( - target.root().join(".lock"), - target.root().simplified_display(), - ) + LockedFile::acquire(target.root().join(".lock"), target.root().user_display()) } else if self.0.interpreter.is_virtualenv() { // If the environment a virtualenv, use a virtualenv-specific lock file. - LockedFile::acquire(self.0.root.join(".lock"), self.0.root.simplified_display()) + LockedFile::acquire(self.0.root.join(".lock"), self.0.root.user_display()) } else { // Otherwise, use a global lock file. LockedFile::acquire( env::temp_dir().join(format!("uv-{}.lock", cache_key::digest(&self.0.root))), - self.0.root.simplified_display(), + self.0.root.user_display(), ) } }