Skip to content

Commit

Permalink
fix(update/uninstall): Remove items from PATH correctly (#5833)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Mar 20, 2024
1 parent 9d07c33 commit 3186fef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions lib/install.ps1
Expand Up @@ -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."
}
Expand All @@ -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
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions libexec/scoop-update.ps1
Expand Up @@ -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")) {
Expand Down

0 comments on commit 3186fef

Please sign in to comment.