From 7326fa6a769c4d52e05bceece2d9939ccde3f2bb Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Wed, 20 Mar 2024 15:07:59 +0800 Subject: [PATCH 1/2] fix(uninstall): Remove items from PATH correctly --- lib/install.ps1 | 15 ++++++++++----- libexec/scoop-update.ps1 | 5 ++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/install.ps1 b/lib/install.ps1 index 3fe945229a..0ed13707e8 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -917,7 +917,6 @@ function env_add_path($manifest, $dir, $global, $arch) { } else { $path_dir = Join-Path $dir $_ } - if (!(is_in_dir $dir $path_dir)) { abort "Error in manifest: env_add_path '$_' is outside the app directory." } @@ -928,10 +927,16 @@ function env_add_path($manifest, $dir, $global, $arch) { function env_rm_path($manifest, $dir, $global, $arch) { $env_add_path = arch_specific 'env_add_path' $manifest $arch - $env_add_path | Where-Object { $_ } | ForEach-Object { - $path_dir = Join-Path $dir $_ - - remove_from_path $path_dir $global + $dir = $dir.TrimEnd('\') + if ($env_add_path) { + $env_add_path | Where-Object { $_ } | ForEach-Object { + if ($_ -eq '.') { + $path_dir = $dir + } else { + $path_dir = Join-Path $dir $_ + } + remove_from_path $path_dir $global + } } } diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 50f82090a5..e632be72fb 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -289,15 +289,14 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c Write-Host "Uninstalling '$app' ($old_version)" run_uninstaller $old_manifest $architecture $dir rm_shims $app $old_manifest $global $architecture - env_rm_path $old_manifest $dir $global $architecture - env_rm $old_manifest $global $architecture # If a junction was used during install, that will have been used # as the reference directory. Otherwise it will just be the version # directory. $refdir = unlink_current $dir - uninstall_psmodule $old_manifest $refdir $global + env_rm_path $old_manifest $refdir $global $architecture + env_rm $old_manifest $global $architecture if ($force -and ($old_version -eq $version)) { if (!(Test-Path "$dir/../_$version.old")) { From a040431defe4293b3ab253fe05fac62ea212acfe Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Wed, 20 Mar 2024 15:25:02 +0800 Subject: [PATCH 2/2] update chglog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b33caca7ec..c29b636dda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - **core:** Do not call `scoop` externally from inside the code ([#5695](https://github.com/ScoopInstaller/Scoop/issues/5695)) - **scoop-checkup:** Don't throw 7zip error when external 7zip is used ([#5703](https://github.com/ScoopInstaller/Scoop/issues/5703)) - **config:** Warn users about misconfigured GitHub token ([#5777](https://github.com/ScoopInstaller/Scoop/issues/5777)) +- **update/uninstall:** Remove items from PATH correctly ([#5833](https://github.com/ScoopInstaller/Scoop/issues/5833)) ### Performance Improvements