Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **download|scoop-download:** Add GitHub issue prompt when the default downloader fails ([#6539](https://github.com/ScoopInstaller/Scoop/issues/6539))
- **download|scoop-config:** Allow disabling automatic fallback to the default downloader when Aria2c download fails ([#6538](https://github.com/ScoopInstaller/Scoop/issues/6538))
- **checkver:** Set GitHub mode default jsonpath and regex ([#6653](https://github.com/ScoopInstaller/Scoop/issues/6653))
- **scoop-update:** Add `--allow-running` flag to bypass running-process check ([#6342](https://github.com/ScoopInstaller/Scoop/issues/6342), [#6029](https://github.com/ScoopInstaller/Scoop/issues/6029))

### Bug Fixes

Expand Down
27 changes: 23 additions & 4 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# -s, --skip-hash-check Skip hash validation (use with caution!)
# -q, --quiet Hide extraneous messages
# -a, --all Update all apps (alternative to '*')
# -r, --allow-running Allow updating apps that are currently running

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'save_install_info' in 'manifest.ps1' (indirectly)
Expand All @@ -29,7 +30,7 @@ if (get_config USE_SQLITE_CACHE) {
. "$PSScriptRoot\..\lib\database.ps1"
}

$opt, $apps, $err = getopt $args 'gfiksqa' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all'
$opt, $apps, $err = getopt $args 'gfiksqar' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all', 'allow-running'
if ($err) { error "scoop update: $err"; exit 1 }
$global = $opt.g -or $opt.global
$force = $opt.f -or $opt.force
Expand All @@ -38,6 +39,7 @@ $use_cache = !($opt.k -or $opt.'no-cache')
$quiet = $opt.q -or $opt.quiet
$independent = $opt.i -or $opt.independent
$all = $opt.a -or $opt.all
$allowRunning = $opt.r -or $opt.'allow-running'

# load config
$configRepo = get_config SCOOP_REPO
Expand Down Expand Up @@ -399,11 +401,19 @@ if (-not ($apps -or $all)) {
set_config LAST_UPDATE ([System.DateTime]::Now.ToString('o')) | Out-Null
success 'Scoop was updated successfully!'
} else {
if ($global -and !(is_admin)) {
error 'You need admin rights to update global apps.'; exit 1
# --allow-running: temporarily bypass running-process check.
# Scoop uses versioned directories (e.g., pwsh 7.6.1/ -> 7.6.2/),
# so the update creates a new directory without touching the running binary.
if ($allowRunning) {
$savedIgnoreRunning = get_config IGNORE_RUNNING_PROCESSES
set_config IGNORE_RUNNING_PROCESSES $true | Out-Null
}
try {
if ($global -and !(is_admin)) {
error 'You need admin rights to update global apps.'; exit 1
}

$outdated = @()
$outdated = @()
$updateScoop = $null -ne ($apps | Where-Object { $_ -eq 'scoop' }) -or (is_scoop_outdated)
$apps = $apps | Where-Object { $_ -ne 'scoop' }
$apps_param = $apps
Expand Down Expand Up @@ -463,6 +473,15 @@ if (-not ($apps -or $all)) {
$suggested = @{}
# $outdated is a list of ($app, $global) tuples
$outdated | ForEach-Object { update @_ $quiet $independent $suggested $use_cache $check_hash }
} finally {
if ($allowRunning) {
if ($null -ne $savedIgnoreRunning) {
set_config IGNORE_RUNNING_PROCESSES $savedIgnoreRunning | Out-Null
} else {
set_config IGNORE_RUNNING_PROCESSES $false | Out-Null
}
}
}
}

exit 0
Loading