Skip to content
This repository was archived by the owner on Aug 11, 2026. It is now read-only.

Commit 1e09cbf

Browse files
committed
fix: honor --pin when --force is used on already installed extension
When an extension is already installed and the user runs `gh extension install --pin <tag> --force`, the current code routes through the upgrade path which ignores the pin and installs the latest version. This fix removes the existing extension first when --pin is specified, allowing the subsequent install to honor the pin. Fixes cli#13551
1 parent b300f2e commit 1e09cbf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎pkg/cmd/extension/command.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,13 @@ func NewCmdExtension(f *cmdutil.Factory) *cobra.Command {
379379
if ext, err := checkValidExtension(cmd.Root(), m, repo.RepoName(), repo.RepoOwner()); err != nil {
380380
// If an existing extension was found and --force was specified, attempt to upgrade.
381381
if forceFlag && ext != nil {
382-
return upgradeFunc(ext.Name(), forceFlag)
382+
if pinFlag != "" {
383+
if err := m.Remove(ext.Name()); err != nil {
384+
return fmt.Errorf("failed to remove existing extension before pinned reinstall: %w", err)
385+
}
386+
} else {
387+
return upgradeFunc(ext.Name(), forceFlag)
388+
}
383389
}
384390

385391
if errors.Is(err, alreadyInstalledError) {

0 commit comments

Comments
 (0)