Skip to content

[errors] Show nicer error when installing a package that is not supported by current system #1279

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

Merged
merged 7 commits into from
Jul 19, 2023

Conversation

mikeland73
Copy link
Contributor

@mikeland73 mikeland73 commented Jul 17, 2023

Summary

Shows better error messages in following cases:

  • When package doesn't exist on search or in nixpkgs as attribute path
  • When package is not supported by current platform

How was it tested?

devbox add [email protected]
devbox add fuse3

image

@mikeland73 mikeland73 requested review from gcurtis and ipince July 17, 2023 18:46
Copy link
Collaborator

@gcurtis gcurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty close, but I think if we just try evaluating the derivation we could catch more errors. Would that work?

@@ -46,6 +46,21 @@ func PackageKnownVulnerabilities(path string) []string {
return vulnerabilities
}

func PackagePlatforms(path string) []string {
cmd := command("eval", path+".meta.platforms", "--json")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead of searching and eval'ing the platforms we just eval the derivation's outPath and check the output? For example:

# Bad
$ nix eval --raw nixpkgs#fuse3
error: Package ‘fuse-3.11.0’ in /nix/store/b63zicy7mkwlp4vmca056kawsrmxfr36-source/pkgs/os-specific/linux/fuse/common.nix:92 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
...

vs.

# Good
$ nix eval --raw nixpkgs#fuse 
/nix/store/8pqmbsp8zkq8656k5yaravbaxixaaa3c-macfuse-stubs-4.4.1

@mikeland73 mikeland73 marked this pull request as draft July 17, 2023 21:21
@mikeland73 mikeland73 marked this pull request as ready for review July 17, 2023 21:32
@mikeland73
Copy link
Contributor Author

@gcurtis PTAL

@mikeland73 mikeland73 merged commit 778c8d2 into main Jul 19, 2023
@mikeland73 mikeland73 deleted the landau/better-error branch July 19, 2023 23:02
savil added a commit that referenced this pull request Aug 12, 2023
…th installing package that is uninstallable on user's platform (#1364)

## Summary

Changes the error message to suggest using
`--platform/--exclude-platform` with `devbox add`.

I wish we had a way to recommend the platforms that are supported for
the exact package being installed, but we don't.

The heavy lifting for this was done in #1279. Thanks @mikeland73!

## How was it tested?

```
> devbox add glibcLocales

Installing package: glibcLocales.


Error: package glibcLocales cannot be installed on your platform x86_64-darwin. Consider using `--platform` or `--exclude-platform` with `devbox add` to install on a supported platform. Other available platforms are: aarch64-darwin, aarch64-linux, i686-linux, x86_64-linux, armv7l-linux.
```

<img width="949" alt="Screenshot 2023-08-10 at 4 20 18 PM"
src="https://github.com/jetpack-io/devbox/assets/676452/95ddff88-793b-4c09-9e65-be344d303c2a">
mikeland73 added a commit that referenced this pull request Sep 8, 2023
…1463)

## Summary

Restores functionality implemented by
#1264 and refactored in
#1279

which was accidentally broken by
#1437

tldr: the `FillNarInfoCache` function breaks if packages are not in
search, but we support non-search packages via fallback (.e.g.
stdenv.cc.cc.lib)

I'm keeping surface area as small as possible, but as a follow up I
think we can remove the `devpkg.FillNarInfoCache` calls from `impl.Add`
if we simply ignore the`IsInBinaryCache` errors in
[ValidateExists](https://github.com/jetpack-io/devbox/blob/main/internal/devpkg/validation.go#L10-L26)
or remove `IsInBinaryCache` from that function completely (I'm not
convinced it is needed, @savil @ipince correct me if I'm wrong)

## How was it tested?
`devbox add stdenv.cc.cc.lib`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants