Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/tower-uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ impl Uv {
}
}

// Without an explicit cache dir, uv's default cache may be on a different
// filesystem than the target venv, so hardlinking fails and uv warns before
// falling back to a copy. Force copy mode to skip the failed attempt and the
// warning.
fn apply_link_mode(&self, cmd: &mut Command) {
if self.cache_dir.is_none() {
cmd.env("UV_LINK_MODE", "copy");
}
}

pub async fn venv(
&self,
cwd: &PathBuf,
Expand Down Expand Up @@ -361,6 +371,7 @@ impl Uv {
if let Some(dir) = &self.cache_dir {
cmd.arg("--cache-dir").arg(dir);
}
self.apply_link_mode(&mut cmd);

let child = cmd.spawn()?;

Expand Down Expand Up @@ -406,6 +417,7 @@ impl Uv {
.arg("never")
.arg("pip")
.arg("install");
self.apply_link_mode(&mut cmd);
cmd
}

Expand Down Expand Up @@ -494,6 +506,8 @@ impl Uv {

// Need to do this after env_clear intentionally.
cmd.envs(env_vars);
// Also after env_clear so protected mode doesn't wipe it.
self.apply_link_mode(&mut cmd);

if let Some(dir) = &self.cache_dir {
cmd.arg("--cache-dir").arg(dir);
Expand Down
Loading