From c8e11a8f9817bc780cb5858a946e5845788badd5 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 5 Jan 2020 00:32:56 +0100 Subject: Fix PATH getting wiped on Windows during install There was no variable expansion called for %PATH% in setx PATH ;%PATH% effectively replacing PATH with litteraly `;%PATH%`. The fix is simple, the command just needs to be called inside a shell with `cmd /C`. --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index a1450dc..8f5557d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,9 +220,10 @@ fn install() -> Result<()> { #[cfg(target_os = "windows")] { println!("Adding {} to your %PATH%", location.display()); - let mut location = location.into_os_string(); - location.push(";%PATH%"); - let _ = Command::new("setx").arg("PATH").arg(&location).output()?; + let mut command = std::ffi::OsStr::new("setx PATH ").to_os_string(); + command.push(location.into_os_string()); + command.push(";%PATH%"); + let _ = Command::new("cmd").arg("/C").arg(command).output()?; println!("You'll need to restart your computer for the %PATH% changes to take effect"); } println!("Installation complete"); -- cgit v1.2.3