Skip to content
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

Suggested command for creating an extension when an extension doesn't have a binary for the current architecture creates an unclear, blank issue #9600

Closed
timrogers opened this issue Sep 11, 2024 · 2 comments · Fixed by #9608
Labels
gh-extension relating to the gh extension command needs-triage needs to be reviewed

Comments

@timrogers
Copy link
Contributor

timrogers commented Sep 11, 2024

When installing an extension, the CLI must to select the correct binary to download for the machine (see the installBin function).

By default, the CLI will download a binary matching the current machine's architecture.

If a suitable binary isn't available, the CLI outputs an error, directing the user to create an issue on the extension's repository:

if asset == nil {
	return fmt.Errorf(
		"%[1]s unsupported for %[2]s. Open an issue: `gh issue create -R %[3]s/%[1]s -t'Support %[2]s'`",
		repo.RepoName(), platform, repo.RepoOwner())
}

The issue this creates isn't very clear or helpful. It isn't obvious where it is coming from, or what you need to do.

I would propose that we create that issue with a body, e.g.:

This GitHub CLI extension does not support the %[2]s architecture. I tried to install it on a %[2]s machine, and it failed due to the lack of an available binary. Would you be able to update the extension's build and release process to include the relevant binary? For more details, see https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions.

This issue body was generated automatically by the GitHub CLI.

Related to #9592.

@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Sep 11, 2024
@timrogers
Copy link
Contributor Author

I'm willing to pick up this change, if the maintainers are happy to accept it 😊

@andyfeller
Copy link
Contributor

Thanks for raising this concern, @timrogers, definitely an opportunity to improve extension authors and users interactions!

At first, I was wondering whether there were other situations we could land in this such as the repo not existing, however I see we have that covered:

func (m *Manager) Install(repo ghrepo.Interface, target string) error {
isBin, err := isBinExtension(m.client, repo)
if err != nil {
if errors.Is(err, releaseNotFoundErr) {
if ok, err := repoExists(m.client, repo); err != nil {
return err
} else if !ok {
return repositoryNotFoundErr
}
} else {
return fmt.Errorf("could not check for binary extension: %w", err)
}
}
if isBin {
return m.installBin(repo, target)
}
hs, err := hasScript(m.client, repo)
if err != nil {
return err
}
if !hs {
return errors.New("extension is not installable: missing executable")
}
return m.installGit(repo, target)
}

$ gh ext install andyfeller/gh-doesnotexist
X Could not find extension 'andyfeller/gh-doesnotexist' on host github.com

The only other scenario being an error with the build process that fails to upload the specific OS + architecture, but realizing that likely warrants asking the extension author to do something regardless.

What might this look like? 🤔

  • Whatever we output, we should ensure it works for Mac / Windows / Linux users; meaning we probably can't use fancy tricks like sh-style heredocs to generate issue body in an elaborate way:

    For example, cli/cli triage workflow:

    cat << EOF | gh issue create --title "Triage issue \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label triage
    **Title:** $TITLE
    **Issue:** $LINK
    **Created:** $CREATED
    **Triggered by:** @$TRIGGERED_BY
    
    ---
    
    > $BODY
    EOF
  • Ideally this wouldn't be super verbose command for the user to run

With all of that said, I think this makes sense and can hold off further feedback for a PR.

timrogers added a commit to timrogers/cli that referenced this issue Sep 12, 2024
… doesn't have a binary for your platform

When installing an extension, the CLI must to select the correct
binary to download for the machine (see the
[`installBin` function](https://github.com/cli/cli/blob/78c1d00eccac1b2ae82ac0bfeea3e2292c98056a/pkg/cmd/extension/manager.go#L240)).

By default, the CLI will download a binary matching the current
machine's architecture.

If a suitable binary isn't available, the CLI
[outputs an error](https://github.com/cli/cli/blob/78c1d00eccac1b2ae82ac0bfeea3e2292c98056a/pkg/cmd/extension/manager.go#L278),
directing the user to create an issue on the extension's
repository:

```go
if asset == nil {
	return fmt.Errorf(
		"%[1]s unsupported for %[2]s. Open an issue: `gh issue create -R %[3]s/%[1]s -t'Support %[2]s'`",
		repo.RepoName(), platform, repo.RepoOwner())
}
```

The issue this creates isn't very clear or helpful. It isn't
obvious where it is coming from, or what you need to do.

This improves the suggested command, adding a better title
to the issue and an explanatory body.

To test this, try installing my
`timrogers/gh-extension-without-binary` extension, which only has
an esoteric `linux-ppc64` binary 😸:

```bash
gh extension install timrogers/gh-extension-without-binary
```

You'll get a nice output like this:

```
gh-extension-without-binary unsupported for darwin-arm64. Open an issue: `gh issue create -R timrogers/gh-extension-without-binary --title "Add support for the darwin-arm64 architecture" --body "This extension does not support the darwin-arm64 architecture. I tried to install it on a darwin-arm64 machine, and it failed due to the lack of an available binary. Would you be able to update the extension's build and release process to include the relevant binary? For more details, see <https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions>."`
```

...which produces an issue like
timrogers/gh-extension-without-binary#4.

I have tested the resulting command on macOS and Windows, so
I am confident that it has *at least reasonable* cross-platform
support.

Fixes cli#9600.
@jtmcg jtmcg closed this as completed in dded039 Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gh-extension relating to the gh extension command needs-triage needs to be reviewed
Projects
None yet
3 participants