Skip to content

Commit 5d86577

Browse files
authored
[rm nixpkgs] Add more info on errors for debuggability (#1292)
## Summary * ~Skips packages with missing store versions, since they're needed for the store path.~ * Adds debug line and context to error msg to aid in debugging. A related question: My understanding is that nix store paths are of the form `/nix/store/<hash>-<pkg>`, and _not_ of the form `/nix/store/<hash>-<pkg>-<version>`. Meaning that some (most) package names just add the version suffix as convention. So I'm a bit worried about trying to parse the version from the name and then essentially reconstructing that here. Would prefer to just pass the untouched pkg name and use that. @gcurtis why do we parse out the version separately (if that's what we're doing)? Another thing is I noticed that as long as the hash we pass to `nix store make-content-addressed` is correct, then the rest doesn't matter. Example: ``` > nix store make-content-addressed /nix/store/glb4gpim82f0bmzcpayvklbfqc6qzvwj-this-does-not-matter --json asked 'https://cache.nixos.org' for '/nix/store/glb4gpim82f0bmzcpayvklbfqc6qzvwj-this-does-not-matter' but got '/nix/store/glb4gpim82f0bmzcpayvklbfqc6qzvwj-jq-1.6-bin' # <-- the path we want. ``` We could potentially try to recover from errors by using the path in that response. (Update: I think it's ok to just fail instead of trying to parse the response and recovering). ## How was it tested? Manually by returning fake data from the calls to the search service.
1 parent 2f0e8eb commit 5d86577

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/lock/resolve.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/pkg/errors"
1111
"go.jetpack.io/devbox/internal/boxcli/featureflag"
1212
"go.jetpack.io/devbox/internal/boxcli/usererr"
13+
"go.jetpack.io/devbox/internal/debug"
1314
"go.jetpack.io/devbox/internal/nix"
1415
"go.jetpack.io/devbox/internal/searcher"
1516
"golang.org/x/exp/maps"
@@ -91,6 +92,7 @@ func buildLockSystemInfos(pkg *searcher.PackageVersion) (map[string]*SystemInfo,
9192

9293
// guard against missing search data
9394
if sysInfo.StoreHash == "" || sysInfo.StoreName == "" {
95+
debug.Log("WARN: skipping %s in %s due to missing store name or hash", pkg.Name, sysName)
9496
continue
9597
}
9698

@@ -99,7 +101,7 @@ func buildLockSystemInfos(pkg *searcher.PackageVersion) (map[string]*SystemInfo,
99101
if sysName == userSystem {
100102
caStorePath, err = nix.ContentAddressedStorePath(storePath)
101103
if err != nil {
102-
return nil, err
104+
return nil, errors.WithMessagef(err, "failed to make content addressed path for %s", storePath)
103105
}
104106
}
105107
sysInfos[sysName] = &SystemInfo{

0 commit comments

Comments
 (0)