From 51cf09daf326e28ea98d62652ad35ef056fb55e1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 9 Jul 2025 21:38:45 +0700 Subject: [PATCH] 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 --- build/runner/src/pyenv.rs | 12 ++++++++++-- qt/launcher/src/main.rs | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/build/runner/src/pyenv.rs b/build/runner/src/pyenv.rs index f514096fb..9d65626ca 100644 --- a/build/runner/src/pyenv.rs +++ b/build/runner/src/pyenv.rs @@ -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( - Command::new(args.uv_bin) - .env_clear() + command .env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone()) .args(["sync", "--locked", "--no-config"]) .args(args.extra_args), diff --git a/qt/launcher/src/main.rs b/qt/launcher/src/main.rs index 34a81a622..15548d3bc 100644 --- a/qt/launcher/src/main.rs +++ b/qt/launcher/src/main.rs @@ -257,9 +257,16 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re // Prepare to sync the venv 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 - .current_dir(&state.uv_install_root) - .env_clear() .env("UV_CACHE_DIR", &state.uv_cache_dir) .env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir) .args(["sync", "--upgrade", "--managed-python", "--no-config"]);