Skip to content

Commit 4af863e

Browse files
committed
[Config Packages] Suggest --platform/--exclude-platform upon error with installing package that is uninstallable on user's platform
1 parent f65133a commit 4af863e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

internal/nix/nix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ var nixPlatforms = []string{
182182
"armv7l-linux",
183183
}
184184

185+
func SupportedPlatforms() []string {
186+
return nixPlatforms
187+
}
188+
185189
// EnsureValidPlatform returns an error if the platform is not supported by nix.
186190
// https://nixos.org/manual/nix/stable/installation/supported-platforms.html
187191
func EnsureValidPlatform(platform string) error {

internal/nix/nixprofile/profile.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/fatih/color"
1515
"github.com/pkg/errors"
16+
"github.com/samber/lo"
1617
"go.jetpack.io/devbox/internal/boxcli/usererr"
1718
"go.jetpack.io/devbox/internal/devpkg"
1819
"go.jetpack.io/devbox/internal/lock"
@@ -265,9 +266,22 @@ func ProfileInstall(args *ProfileInstallArgs) error {
265266
if exists, err := input.ValidateInstallsOnSystem(); err != nil {
266267
return err
267268
} else if !exists {
269+
platform, err := nix.System()
270+
if err != nil {
271+
platform = ""
272+
} else {
273+
platform = " " + platform
274+
}
275+
otherPlatforms := lo.Filter(nix.SupportedPlatforms(), func(p string, _ int) bool {
276+
return p != platform
277+
})
268278
return usererr.New(
269-
"package %s cannot be installed on your system. It may be installable on other systems.",
279+
"package %s cannot be installed on your platform%s. "+
280+
"Consider using `--platform` or `--exclude-platform` with `devbox add` to install on a supported"+
281+
" platform. Other available platforms are: %s.",
270282
input.String(),
283+
platform,
284+
strings.Join(otherPlatforms, ", "),
271285
)
272286
}
273287
}

0 commit comments

Comments
 (0)