-
Notifications
You must be signed in to change notification settings - Fork 843
Fix install script swallowing file-lock errors and reporting false success #15419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
7362786
ac00fa2
5f99dc6
1830f02
c2efe75
8056486
3518336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -633,7 +633,12 @@ function Backup-ExistingCliExecutable { | |||||||||||||||||||||||
| Write-Message "Backing up existing CLI: $TargetExePath -> $backupPath" -Level Verbose | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Rename existing executable to .old.[timestamp] | ||||||||||||||||||||||||
| Move-Item -Path $TargetExePath -Destination $backupPath -Force | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| Move-Item -Path $TargetExePath -Destination $backupPath -Force -ErrorAction Stop | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| catch { | ||||||||||||||||||||||||
| throw "Failed to back up existing CLI at '$TargetExePath'. The file may be in use by another process. Please close any running Aspire CLI instances and try again. Error: $($_.Exception.Message)" | ||||||||||||||||||||||||
|
Comment on lines
637
to
+642
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| return $backupPath | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
@@ -659,7 +664,7 @@ function Restore-CliExecutableFromBackup { | |||||||||||||||||||||||
| Remove-Item -Path $TargetExePath -Force -ErrorAction SilentlyContinue | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Move-Item -Path $BackupPath -Destination $TargetExePath -Force | ||||||||||||||||||||||||
| Move-Item -Path $BackupPath -Destination $TargetExePath -Force -ErrorAction Stop | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+669
to
670
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -711,7 +716,7 @@ function Expand-AspireCliArchive { | |||||||||||||||||||||||
| # Create destination directory if it doesn't exist | ||||||||||||||||||||||||
| if (-not (Test-Path $DestinationPath)) { | ||||||||||||||||||||||||
| Write-Message "Creating destination directory: $DestinationPath" -Level Verbose | ||||||||||||||||||||||||
| New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null | ||||||||||||||||||||||||
| New-Item -ItemType Directory -Path $DestinationPath -Force -ErrorAction Stop | Out-Null | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| # Backup existing executable before extraction | ||||||||||||||||||||||||
|
|
@@ -725,7 +730,7 @@ function Expand-AspireCliArchive { | |||||||||||||||||||||||
| throw "Expand-Archive cmdlet not found. Please use PowerShell 5.0 or later to extract ZIP files." | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Expand-Archive -Path $ArchiveFile -DestinationPath $DestinationPath -Force | ||||||||||||||||||||||||
| Expand-Archive -Path $ArchiveFile -DestinationPath $DestinationPath -Force -ErrorAction Stop | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| # Use tar for tar.gz files on Unix systems | ||||||||||||||||||||||||
|
|
@@ -737,6 +742,9 @@ function Expand-AspireCliArchive { | |||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| Set-Location $DestinationPath | ||||||||||||||||||||||||
| & tar -xzf $ArchiveFile | ||||||||||||||||||||||||
| if ($LASTEXITCODE -ne 0) { | ||||||||||||||||||||||||
| throw "tar command failed with exit code $LASTEXITCODE" | ||||||||||||||||||||||||
|
Comment on lines
746
to
+748
|
||||||||||||||||||||||||
| & tar -xzf $ArchiveFile | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "tar command failed with exit code $LASTEXITCODE" | |
| $tarOutput = & tar -xzf $ArchiveFile 2>&1 | |
| $tarExitCode = $LASTEXITCODE | |
| if ($tarExitCode -ne 0) { | |
| $message = "tar command failed for archive '$ArchiveFile' with exit code $tarExitCode." | |
| if ($tarOutput) { | |
| $message += " Output:`n$tarOutput" | |
| } | |
| throw $message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore-CliExecutableFromBackupnow usesMove-Item -ErrorAction Stop, which will throw if the restore fails (e.g., the target is still locked). InExpand-AspireCliArchivethe restore call in the catch block isn’t wrapped, so a restore failure will abort the catch block and can hide the original extraction error. Consider handling restore failures insideExpand-AspireCliArchiveso the final error surfaced to the user retains the primary failure cause while still reporting any restore failure.