-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Here's an example fix. The problem is that $HOME is defined but we sub it with $env:HOME
# Apply the additions to the system PATH
$global:_ENVR_PATH_ADDITIONS.GetEnumerator().ForEach({
$key = $($_.Key)
$val = $($_.Value)
if ($null -eq $val) {
continue
}
# expand the variables - Windows could have $env:<val> or $<val>
$env_val = $ExecutionContext.InvokeCommand.ExpandString($val.Replace('$', '$env:'))
$exp_val = $ExecutionContext.InvokeCommand.ExpandString($val)
if ((Test-Path -Path "$env_val") -and (Test-Path -Path "$exp_val")) {
Write-Host "ERROR - $key=$val is ambigious because both $env_val and $exp_val are valid paths" -ForegroundColor Red
unsource
exit 1
}
if (Test-Path -Path "$env_val") {
$path_addition = $env_val
} elseif (Test-Path -Path "$exp_val") {
$path_addition = $exp_val
} else {
Write-Host "ERROR - $key=$val is not a directory." -ForegroundColor Red
unsource
exit 1
}
foreach ($folder in $(Get-Item env:path).value.split($([System.IO.Path]::PathSeparator))) {
if ($folder -eq $path_addition) {
$duplicate = 1
}
}
if ($duplicate -eq 1) {
continue
}
$Env:PATH = "$path_addition$([System.IO.Path]::PathSeparator)$Env:PATH"
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels