Skip to content

Fix install script swallowing file-lock errors and reporting false success#15419

Open
Copilot wants to merge 9 commits intomainfrom
copilot/fix-aspire-install-error-message
Open

Fix install script swallowing file-lock errors and reporting false success#15419
Copilot wants to merge 9 commits intomainfrom
copilot/fix-aspire-install-error-message

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

When CLI installation hits a filesystem error, especially a locked aspire.exe on Windows, parts of the PowerShell install flow were relying on commands that emit non-terminating errors. That allowed the script to continue after a failed backup or extraction step and still print the success message.

Changes

Applies to eng/scripts/get-aspire-cli.ps1 and eng/scripts/get-aspire-cli-pr.ps1.

  • Harden install/update filesystem operations by adding -ErrorAction Stop where failure should abort the operation.
  • Update Backup-ExistingCliExecutable to remove stale *.old.* backups before creating a new backup, matching self-update behavior.
  • Wrap the backup Move-Item in try/catch and throw a clearer, actionable error when the existing CLI cannot be moved because it is in use.
  • Make Expand-Archive failures terminating so the existing restore/error path runs instead of falling through to the success message.
  • In get-aspire-cli.ps1, check $LASTEXITCODE after tar extraction so Unix extraction failures are surfaced correctly.
  • Capture tar stdout/stderr and include it in the thrown extraction error when tar exits non-zero.
  • Preserve the original unpack error if restore from backup also fails, so rollback problems do not mask the root cause.
  • Only clean up old backup files after the target executable exists.

Result

If the installer cannot replace the existing CLI, or if extraction/rollback fails, it now fails with clear actionable errors instead of reporting a successful install.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Original prompt

This section details on the original issue you should resolve

<issue_title>aspire install ps1 shows error message but then reports it succeeded when it didn't</issue_title>
<issue_description>On Windows, I had the staging channel of the CLI already installed.

Then I ran irm https://aspire.dev/install.ps1 | iex to install latest stable and this is what I saw:

➜ irm https://aspire.dev/install.ps1 | iex
Downloading aspire-cli-win-x64.zip from 'ga/daily'
Move-Item:
Line |
 636 |              Move-Item -Path $TargetExePath -Destination $backupPath - …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The process cannot access the file because it is being used by another process.
Remove-Item: The process cannot access the file 'C:\Users\dedward\.aspire\bin\aspire.exe' because it is being used by another process.
Aspire CLI successfully installed to: C:\Users\dedward\.aspire\bin\aspire.exe

The aspire cli is now available for use in this and new sessions.

It seems it failed to perform the logical rename of the downloaded file because the existing aspire.exe was locked by another process. Oddly I couldn't find any instances of aspire.exe already running?

A few issues here:

  • The exception is uncaught and bubbles up as a raw error to the end user
  • The script continues and renders the success message
  • The install didn't actually succeed as I still have the staging version (13.2 in this case) installed

Image</issue_description>

<agent_instructions>Improve error handling so we correctly when the files cannot be moved to the target location. Also, look for other missing or ignored error handling.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

… success messages

When aspire.exe was locked by another process, Move-Item in
Backup-ExistingCliExecutable failed as a non-terminating error and execution
continued, causing Expand-Archive to also fail silently and the success
message to be displayed regardless.

- Wrap Move-Item in Backup-ExistingCliExecutable with try/catch +
  -ErrorAction Stop in both get-aspire-cli.ps1 and get-aspire-cli-pr.ps1,
  throwing a clear actionable message when the backup fails
- Add -ErrorAction Stop to Expand-Archive in both scripts so extraction
  failures are caught by the existing catch block
- Add exit-code check for tar in get-aspire-cli.ps1 (pr variant already had it)

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix erroneous success message in aspire install ps1 Fix install script swallowing file-lock errors and reporting false success Mar 20, 2026
Copilot AI requested a review from radical March 20, 2026 01:00
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15419

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15419"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@radical radical marked this pull request as ready for review March 20, 2026 03:42
Copilot AI review requested due to automatic review settings March 20, 2026 03:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves robustness of the Aspire CLI install PowerShell scripts by converting previously non-terminating file operation failures (notably when aspire.exe is locked) into terminating errors that are properly caught and reported, preventing false “success” output.

Changes:

  • Make backup/restore of existing CLI executable fail fast (-ErrorAction Stop) and surface an actionable error when backup can’t be created.
  • Ensure archive extraction failures are terminating (Expand-Archive -ErrorAction Stop) so the existing try/catch logic runs (including backup restore).
  • Add Unix tar exit-code validation in get-aspire-cli.ps1 (PR variant already had this behavior).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
eng/scripts/get-aspire-cli.ps1 Harden backup/restore + extraction paths to avoid swallowed errors and false success; add tar exit-code check.
eng/scripts/get-aspire-cli-pr.ps1 Align PR installer with the same backup/restore + extraction error handling improvements.

@radical radical marked this pull request as draft March 20, 2026 03:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

@github-actions
Copy link
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

radical and others added 3 commits March 20, 2026 14:54
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…install-error-message' into copilot/fix-aspire-install-error-message
@github-actions
Copy link
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@radical radical marked this pull request as ready for review March 23, 2026 20:52
radical and others added 2 commits March 24, 2026 12:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

🎬 CLI E2E Test Recordings — 49 recordings uploaded (commit 29134fc)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23501668867

@radical radical enabled auto-merge (squash) March 24, 2026 18:30
@radical radical requested a review from eerhardt March 24, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire install ps1 shows error message but then reports it succeeded when it didn't

3 participants