Skip to content

Conversation

@sliekens
Copy link
Contributor

@sliekens sliekens commented Jan 1, 2026

Fixes #13140

Description

Previously, aspire update --self always installed to $HOME/.aspire/bin regardless of where the CLI was originally installed. This caused issues when the CLI was installed to a custom path like /usr/local/bin using --install-path.

Now the command installs the update to the same directory as the currently running CLI executable, determined via Environment.ProcessPath. If the update fails due to insufficient permissions (e.g., writing to a protected directory like /usr/local/bin), a helpful error message is displayed advising the user to run with elevated permissions.

The changes were tested manually with:

artifacts/bin/Aspire.Cli/Debug/net10.0/aspire update --self --debug

Permission error handling was tested on Linux with:

chmod -w -R artifacts/bin/Aspire.Cli/Debug/net10.0/
artifacts/bin/Aspire.Cli/Debug/net10.0/aspire update --self --debug
image image

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No: missing translations, I don't know how translations are handled
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No: the UnauthorizedAccessException path requires real filesystem permission restrictions that are difficult to reliably trigger in unit tests without mocking infrastructure. The existing 21 tests continue to pass.
  • 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?

Previously, `aspire update --self` always installed to `$HOME/.aspire/bin`
regardless of where the CLI was originally installed. This caused issues
when the CLI was installed to a custom path like `/usr/local/bin` using
`--install-path`.

Now the command installs the update to the same directory as the currently
running CLI executable, determined via `Environment.ProcessPath`. If the
update fails due to insufficient permissions (e.g., writing to a protected
directory like `/usr/local/bin`), a helpful error message is displayed
advising the user to run with elevated permissions.

Fixes dotnet#13140
Copilot AI review requested due to automatic review settings January 1, 2026 17:12
@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13722

Or

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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 1, 2026
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

This PR fixes a bug where aspire update --self always installed to $HOME/.aspire/bin regardless of the CLI's original installation location. The fix makes the command install updates to the same directory as the currently running CLI executable, determined via Environment.ProcessPath. It also adds proper error handling for permission issues when updating to protected directories like /usr/local/bin.

Key Changes

  • Changed installation directory detection from hardcoded $HOME/.aspire/bin to the directory of the currently running CLI executable
  • Added UnauthorizedAccessException handling with a helpful error message advising users to run with elevated permissions
  • Added new localized resource string NoWritePermissionToInstallDirectory across all supported languages

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

File Description
src/Aspire.Cli/Commands/UpdateCommand.cs Updated ExtractAndUpdateAsync to use Environment.ProcessPath instead of home directory, added exception handling for permission errors
src/Aspire.Cli/Resources/UpdateCommandStrings.resx Added new error message resource for permission issues
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs Added resource accessor property for the new error message
src/Aspire.Cli/Resources/xlf/*.xlf Added new untranslated resource strings to all 13 localization files (cs, de, es, fr, it, ja, ko, pl, pt-BR, ru, tr, zh-Hans, zh-Hant)
Files not reviewed (1)
  • src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CLI] aspire update --self does not install to current CLI location

1 participant