Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion crates/uv-virtualenv/src/activator/activate.nu
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export-env {
}
}

let virtual_env = '{{ VIRTUAL_ENV_DIR }}'
let virtual_env = {{ VIRTUAL_ENV_DIR }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't the quotes be important in case there are spaces in the file path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let bin = '{{ BIN_NAME }}'
let path_name = if (has-env 'Path') { 'Path' } else { 'PATH' }
let venv_path = ([$virtual_env $bin] | path join)
Expand Down
9 changes: 8 additions & 1 deletion crates/uv-virtualenv/src/virtualenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,15 @@ pub(crate) fn create(
(true, "activate.fish") => {
r#"'"$(dirname -- "$(cd "$(dirname -- "$(status -f)")"; and pwd)")"'"#.to_string()
}
(true, "activate.nu") => r#"(path self | path dirname | path dirname)"#.to_string(),
(false, "activate.nu") => {
format!(
"'{}'",
escape_posix_for_single_quotes(location.simplified().to_str().unwrap())
)
}
// Note:
// * relocatable activate scripts appear not to be possible in csh and nu shell
// * relocatable activate scripts appear not to be possible in csh.
// * `activate.ps1` is already relocatable by default.
_ => escape_posix_for_single_quotes(location.simplified().to_str().unwrap()),
};
Expand Down
6 changes: 6 additions & 0 deletions crates/uv/tests/it/venv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,12 @@ fn verify_pyvenv_cfg_relocatable() {
let activate_fish = scripts.child("activate.fish");
activate_fish.assert(predicates::path::is_file());
activate_fish.assert(predicates::str::contains(r#"set -gx VIRTUAL_ENV ''"$(dirname -- "$(cd "$(dirname -- "$(status -f)")"; and pwd)")"''"#));

let activate_nu = scripts.child("activate.nu");
activate_nu.assert(predicates::path::is_file());
activate_nu.assert(predicates::str::contains(
r#"let virtual_env = (path self | path dirname | path dirname)"#,
));
}

/// Ensure that a nested virtual environment uses the same `home` directory as the parent.
Expand Down
Loading