Skip to content

Allow forcibly installing an extension #7096

@heaths

Description

@heaths

Describe the feature or problem you’d like to solve

When using extensions in automation, there's no good way to make sure they are installed. For example, https://gist.github.com/heaths/c24b870041929bc3c3e8e5861c695abb#file-copy-azsdkissue-ps1-L26-L36 checks if the extension is installed and conditionally installs or upgrades it to the latest. It's two additional calls to the GitHub CLI and may not be an obvious solution to everyone. If an extension is already installed on an agent (cached, or from a previous step) an error occurs and likely will terminate the script.

Proposed solution

Support a --force flag that would replace an existing command with the latest version. This would still return an error if the extension wasn't found, couldn't be downloaded or extracted, etc. If --force it would effectively go down the gh ext upgrade path including not downloading the extension if its the latest (assuming that information is available e.g., binary tagged extensions).

This way, automation simply needs to run:

gh ext install {extension} --force

Alternate solution

Making sure the extension is at the latest may not always be necessary - perhaps even rarely, given even ephemeral build agents would at some point likely grab the latest, and this proposal is really geared toward CIs anyway; though, dev scripts could benefit as well.

Alternatively, a flag that doesn't fail if it's already installed would also be great. Simply redirecting stderr to /dev/null and ignoring the exit code could hide valid errors like those mentioned above. Maybe something like --ensure. Or could this even be made default behavior? As mentioned above, this could simply check if the extension is installed and skip any sort of upgrade behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions