Skip to content

Commit 9e80322

Browse files
authored
fix: do not truncate system PATH in win installer (#5243)
The path.nsh script in the NSIS installer provided methods for adding paths to the PATH and removing them. It would do this by reading the current PATH value from the registry, adding the new value (if it doesn't exist) and then writing it to the registry. Unfortunately, it would read from the user's PATH and write the updated result to the system PATH, which would remove important PATH entries like the following in the process: - C:\Windows\System32 - C:\Windows - C:\Windows\System32\wbem - C:\Windows\System32\WindowsPowerShell\v1.0 - C:\Windows\System32\OpenSSH - C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR - C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common and would copy all user environment variables in their place. The variables listed above were the ones missing from my machine when I compared with a friend's machine. Recommended course of action for affected users: 1. Add the paths listed above to your system PATH if they aren't there already and exist on your system. 2. Remove any paths that are in your user's PATH from your system PATH. The existing installers for the last couple of versions of Coder have been yanked from GitHub releases and this message will be included in the release notes for the next patch. Thanks to @cmor for finding and reporting this bug in #5240.
1 parent ab3b3d5 commit 9e80322

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

scripts/win-installer/path.nsh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@
2020

2121
!include "WinMessages.nsh"
2222

23-
; Registry Entry for environment (NT4,2000,XP)
24-
; All users:
23+
; Registry Entry for system environment (NT4,2000,XP)
2524
!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
26-
; Current user only:
27-
;!define Environ 'HKCU "Environment"'
2825

2926

30-
; AddToPath - Appends dir to PATH
27+
; AddToPath - Appends dir to system PATH
3128
; (does not work on Win9x/ME)
3229
;
3330
; Usage:
@@ -45,7 +42,7 @@ Function AddToPath
4542
; Native calls are used here to check actual length of PATH
4643

4744
; $4 = RegOpenKey(HKEY_CURRENT_USER, "Environment", &$3)
48-
System::Call "advapi32::RegOpenKey(i 0x80000001, t'Environment', *i.r3) i.r4"
45+
System::Call "advapi32::RegOpenKey(i 0x80000002, t'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', *i.r3) i.r4"
4946
IntCmp $4 0 0 done done
5047
; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2))
5148
; RegCloseKey($3)
@@ -110,7 +107,7 @@ done:
110107
FunctionEnd
111108

112109

113-
; RemoveFromPath - Removes dir from PATH
110+
; RemoveFromPath - Removes dir from system PATH
114111
;
115112
; Usage:
116113
; Push "dir"

0 commit comments

Comments
 (0)