Suggest installing Rosetta when extension installation fails due to missing darwin-arm64 binary, but a darwin-amd64 binary is available
When installing an extension, the CLI must to select the correct binary to download for the machine (see the [`installBin` function](78c1d00ecc/pkg/cmd/extension/manager.go (L240))). By default, the CLI will download a binary matching the current machine's architecture. However, to provide better support for Macs running on Apple Silicon, it will [fall back](78c1d00ecc/pkg/cmd/extension/manager.go (L267-L274)) from `darwin-arm64` to `darwin-amd64` if [Rosetta](https://support.apple.com/en-gb/102527) (Apple's compatibility layer) is installed. If Rosetta isn't installed, this fallback doesn't happen, which can lead to surprising and confusing results when one Mac has Rosetta and another doesn't, because the extension will install on one machine but not another. In the situation where a `darwin-arm64` binary isn't available but the CLI can't fall back to `amd64` because Rosetta isn't installed, this updates our error message to suggest installing Rosetta. Closes https://github.com/cli/cli/issues/9592.
This commit is contained in:
parent
78c1d00ecc
commit
a0a2567354
1 changed files with 10 additions and 4 deletions
|
|
@ -263,12 +263,18 @@ func (m *Manager) installBin(repo ghrepo.Interface, target string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// if an arm64 binary is unavailable, fall back to amd64 if it can be executed through Rosetta 2
|
||||
if asset == nil && isMacARM && hasRosetta() {
|
||||
// if using an ARM-based Mac and an arm64 binary is unavailable, fall back to amd64 if a relevant binary is available and Rosetta 2 is installed
|
||||
if asset == nil && isMacARM {
|
||||
for _, a := range r.Assets {
|
||||
if strings.HasSuffix(a.Name, "darwin-amd64") {
|
||||
asset = &a
|
||||
break
|
||||
if hasRosetta() {
|
||||
asset = &a
|
||||
break
|
||||
} else {
|
||||
return fmt.Errorf(
|
||||
"%[1]s unsupported for %[2]s. Install Rosetta with `softwareupdate --install-rosetta` to use the available darwin-amd64 binary, or open an issue: `gh issue create -R %[3]s/%[1]s -t'Support %[2]s'`",
|
||||
repo.RepoName(), platform, repo.RepoOwner())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue