-
-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Labels
bugSomething isn't workingSomething isn't workingfundFundable with polar.shFundable with polar.shpowershellwindows
Description
Current Behavior
Code pattern used below will break user's registry key and change it from ExpandString.
| snippet = fmt.Sprintf(`[Environment]::SetEnvironmentVariable("PATH", "%v" + [IO.Path]::PathSeparator + [Environment]::GetEnvironmentVariable("PATH"))`, binDir) |
Expected Behavior
Expect the users Environment Path variable to rename an expand string in the Window's registry.
Steps To Reproduce
carapace _carapace powershell | Out-String | Invoke-Expression without having $env:USERPROFILE\AppData\Romaing\carapace\bin in the Path environment.
Version
carapace-bin 1.5.7
OS
- Darwin
- Linux
- Termux
- Windows
Shell
- Bash
- Elvish
- Fish
- Nushell
- Oil
- Powershell
- Xonsh
- Zsh
Anything else?
See the below issues.
PowerShell/AIShell#406
dotnet/runtime#1442
Also this is how scoop does it in there get.scoop.sh bootstrapper.
https://github.com/ScoopInstaller/Install/blob/ff4eedda58d832b8225d7697510f097ebe8ab071/install.ps1#L379
Please consider the below pattern for setting the user's environment on Windows.
$key = Get-Item 'HKCU:\Environment\'
# Will get the non-expanded values
$existingPath = $key.GetValue('PATH', '', 'DoNotExpandEnvironmentNames')
$newPath = "${existingPath};%TEST_VAR%"
$key.SetValue('PATH', $newPath, 'ExpandString')Or if the current process environment is ok, consider only updating $env:Path.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfundFundable with polar.shFundable with polar.shpowershellwindows