Strip only UV_* env vars

If we don't preserve env vars like TEMP, it results in run failures
on Windows:
https://forums.ankiweb.net/t/anki-25-08-beta/63645/28
This commit is contained in:
Damien Elmes 2025-07-09 21:38:45 +07:00
parent dfbb7302e8
commit 51cf09daf3
2 changed files with 19 additions and 4 deletions

View file

@ -32,9 +32,17 @@ pub fn setup_pyenv(args: PyenvArgs) {
} }
} }
let mut command = Command::new(args.uv_bin);
// remove UV_* environment variables to avoid interference
for (key, _) in std::env::vars() {
if key.starts_with("UV_") {
command.env_remove(key);
}
}
run_command( run_command(
Command::new(args.uv_bin) command
.env_clear()
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone()) .env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
.args(["sync", "--locked", "--no-config"]) .args(["sync", "--locked", "--no-config"])
.args(args.extra_args), .args(args.extra_args),

View file

@ -257,9 +257,16 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re
// Prepare to sync the venv // Prepare to sync the venv
let mut command = Command::new(&state.uv_path); let mut command = Command::new(&state.uv_path);
command.current_dir(&state.uv_install_root);
// remove UV_* environment variables to avoid interference
for (key, _) in std::env::vars() {
if key.starts_with("UV_") {
command.env_remove(key);
}
}
command command
.current_dir(&state.uv_install_root)
.env_clear()
.env("UV_CACHE_DIR", &state.uv_cache_dir) .env("UV_CACHE_DIR", &state.uv_cache_dir)
.env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir) .env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir)
.args(["sync", "--upgrade", "--managed-python", "--no-config"]); .args(["sync", "--upgrade", "--managed-python", "--no-config"]);