From 79ef48549f347288a7656e4cf8968513902c04a7 Mon Sep 17 00:00:00 2001 From: Wyatt Verchere Date: Sun, 23 Apr 2023 10:38:04 -0700 Subject: [PATCH] Windows fix process env vars (#96) * fixes windows issue * clippy --- theseus/src/launcher/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/theseus/src/launcher/mod.rs b/theseus/src/launcher/mod.rs index 2e35fc08..1b914f35 100644 --- a/theseus/src/launcher/mod.rs +++ b/theseus/src/launcher/mod.rs @@ -232,11 +232,12 @@ pub async fn launch_minecraft( .collect::>(), ) .current_dir(instance_path.clone()) - .env_clear() - .envs(env_args) .stdout(Stdio::piped()) .stderr(Stdio::piped()); + // Clear cargo-added env varaibles for debugging, and add settings env vars + clear_cargo_env_vals(&mut command).envs(env_args); + // Create Minecraft child by inserting it into the state // This also spawns the process and prepares the subsequent processes let mut state_children = state.children.write().await; @@ -249,3 +250,12 @@ pub async fn launch_minecraft( ) .await } + +fn clear_cargo_env_vals(command: &mut Command) -> &mut Command { + for (key, _) in std::env::vars() { + if key.starts_with("CARGO") { + command.env_remove(key); + } + } + command +}