From 757ff4e5d4f2119a56751e8e3e5233beeba70202 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 30 Jan 2026 04:16:11 +0000 Subject: [PATCH] Drop `activate.csh` when `--relocatable` is used csh has no way to determine its own script location, so a relocatable activate.csh is not possible. Instead of generating a non-functional script with hardcoded absolute paths, skip it entirely. Closes #17368 https://claude.ai/code/session_013PWav71LZrnY9PVMVFh4sx --- crates/uv-virtualenv/src/virtualenv.rs | 11 ++++++++--- crates/uv/tests/it/venv.rs | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/uv-virtualenv/src/virtualenv.rs b/crates/uv-virtualenv/src/virtualenv.rs index a83979916a12b..a4a02149186ed 100644 --- a/crates/uv-virtualenv/src/virtualenv.rs +++ b/crates/uv-virtualenv/src/virtualenv.rs @@ -447,6 +447,13 @@ pub(crate) fn create( // Add all the activate scripts for different shells for (name, template) in ACTIVATE_TEMPLATES { + // csh has no way to determine its own script location, so a relocatable + // activate.csh is not possible. Skip it entirely instead of generating a + // non-functional script. + if relocatable && *name == "activate.csh" { + continue; + } + let path_sep = if cfg!(windows) { ";" } else { ":" }; let relative_site_packages = [ @@ -477,9 +484,7 @@ pub(crate) fn create( escape_posix_for_single_quotes(location.simplified().to_str().unwrap()) ) } - // Note: - // * relocatable activate scripts appear not to be possible in csh. - // * `activate.ps1` is already relocatable by default. + // Note: `activate.ps1` is already relocatable by default. _ => escape_posix_for_single_quotes(location.simplified().to_str().unwrap()), }; diff --git a/crates/uv/tests/it/venv.rs b/crates/uv/tests/it/venv.rs index 928166d1e0b58..c657184404dd1 100644 --- a/crates/uv/tests/it/venv.rs +++ b/crates/uv/tests/it/venv.rs @@ -1302,6 +1302,11 @@ fn verify_pyvenv_cfg_relocatable() { activate_nu.assert(predicates::str::contains( r"let virtual_env = (path self | path dirname | path dirname)", )); + + // csh cannot determine its own script location, so activate.csh should not + // be generated when --relocatable is used. + let activate_csh = scripts.child("activate.csh"); + activate_csh.assert(predicates::path::missing()); } /// Ensure that a nested virtual environment uses the same `home` directory as the parent.