From d4f961b08a112e213895f5510f08258a635fcc0f Mon Sep 17 00:00:00 2001 From: alaviss Date: Wed, 22 Apr 2020 05:51:18 +0000 Subject: [PATCH] tools/finish: don't quote path with space (#14058) [backport] Path with spaces should be added as is, quoting them makes utilities treat the quotes as part of the path. This makes `nim` unable to be used from the command line even if it appears to be added to user's Path environment variable. Even more confusing, Windows 10's PATH editor shows the path without any quotes, you only see them when you use "Edit text". Took me a good 15 minutes to figure out why couldn't I run `nim` despite it being in Path. (cherry picked from commit 22418ce8fb07d6fd706b16656fba5e8c0e8ba2f4) --- tools/finish.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/finish.nim b/tools/finish.nim index 227b9bcef0..8c92806923 100644 --- a/tools/finish.nim +++ b/tools/finish.nim @@ -123,12 +123,11 @@ when defined(windows): proc addToPathEnv*(e: string) = var p = tryGetUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER) - let x = if e.contains(Whitespace): "\"" & e & "\"" else: e if p.len > 0: p.add ";" - p.add x + p.add e else: - p = x + p = e setUnicodeValue(r"Environment", "Path", p, HKEY_CURRENT_USER) proc createShortcut(src, dest: string; icon = "") =