aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntoine Martin <antoine97.martin@gmail.com>2020-01-05 00:32:56 +0100
committerAntoine Martin <antoine97.martin@gmail.com>2020-01-05 00:41:22 +0100
commitc8e11a8f9817bc780cb5858a946e5845788badd5 (patch)
tree0a5c22b77286cf2c1f6a4d5ce6608f0469dbd3cf /src
parent2aef952141db26df131c201dbe672bce9eafc5d3 (diff)
Fix PATH getting wiped on Windows during install
There was no variable expansion called for %PATH% in setx PATH <dev-suite>;%PATH% effectively replacing PATH with litteraly `<dev-suite>;%PATH%`. The fix is simple, the command just needs to be called inside a shell with `cmd /C`.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs7
1 files changed, 4 insertions, 3 deletions
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");