aboutsummaryrefslogtreecommitdiff
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
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`.
-rw-r--r--.dev-suite/ticket/closed/ds-install-wipes-user-path-on-windows.toml (renamed from .dev-suite/ticket/open/ds-install-wipes-user-path-on-windows.toml)2
-rw-r--r--src/main.rs7
2 files changed, 5 insertions, 4 deletions
diff --git a/.dev-suite/ticket/open/ds-install-wipes-user-path-on-windows.toml b/.dev-suite/ticket/closed/ds-install-wipes-user-path-on-windows.toml
index 73876b5..eb168e9 100644
--- a/.dev-suite/ticket/open/ds-install-wipes-user-path-on-windows.toml
+++ b/.dev-suite/ticket/closed/ds-install-wipes-user-path-on-windows.toml
@@ -1,5 +1,5 @@
title = 'ds install wipes user PATH on Windows'
-status = 'Open'
+status = 'Closed'
id = 'a2448280-2f41-11ea-b9b7-55d06c658ffe'
assignees = []
description = '''
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");