diff --git a/CHANGELOG.md b/CHANGELOG.md index f125069a30..4b7d0fc483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes - **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) +- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/lib/install.ps1 b/lib/install.ps1 index cbe2b2f8b2..6c8c3ff11a 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -60,7 +60,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru create_startmenu_shortcuts $manifest $dir $global $architecture install_psmodule $manifest $dir $global env_add_path $manifest $dir $global $architecture - env_set $manifest $dir $global $architecture + env_set $manifest $global $architecture # persist data persist_data $manifest $original_dir $persist_dir @@ -898,12 +898,12 @@ function env_rm_path($manifest, $dir, $global, $arch) { } } -function env_set($manifest, $dir, $global, $arch) { +function env_set($manifest, $global, $arch) { $env_set = arch_specific 'env_set' $manifest $arch if ($env_set) { - $env_set | Get-Member -Member NoteProperty | ForEach-Object { - $name = $_.name - $val = substitute $env_set.$($_.name) @{ '$dir' = $dir } + $env_set | Get-Member -MemberType NoteProperty | ForEach-Object { + $name = $_.Name + $val = $ExecutionContext.InvokeCommand.ExpandString($env_set.$($name)) Set-EnvVar -Name $name -Value $val -Global:$global Set-Content env:\$name $val } @@ -912,8 +912,8 @@ function env_set($manifest, $dir, $global, $arch) { function env_rm($manifest, $global, $arch) { $env_set = arch_specific 'env_set' $manifest $arch if ($env_set) { - $env_set | Get-Member -Member NoteProperty | ForEach-Object { - $name = $_.name + $env_set | Get-Member -MemberType NoteProperty | ForEach-Object { + $name = $_.Name Set-EnvVar -Name $name -Value $null -Global:$global if (Test-Path env:\$name) { Remove-Item env:\$name } } diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index aeef05cc83..512540e8e6 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -84,7 +84,7 @@ $apps | ForEach-Object { env_rm_path $manifest $dir $global $architecture env_rm $manifest $global $architecture env_add_path $manifest $dir $global $architecture - env_set $manifest $dir $global $architecture + env_set $manifest $global $architecture # unlink all potential old link before re-persisting unlink_persist_data $manifest $original_dir persist_data $manifest $original_dir $persist_dir