gastownhall/beads · error
vendorHash not found in default.nix
Error message
vendorHash not found in default.nix
What it means
fixNixHash locates the vendorHash assignment using the regex `(vendorHash\s*=\s*)"([^"]+)"`. If no match is found in default.nix, the automated repair cannot proceed and this error is returned. This catches default.nix files that don't set vendorHash, or spell it differently (e.g. `vendorSha256` used by older Nixpkgs, or `outputHash` in vendored derivations).
Source
Thrown at cmd/bd/preflight.go:767
)
}
nixPath := "default.nix"
nixInfo, err := os.Stat(nixPath)
if err != nil {
return false, "", "", fmt.Errorf("cannot stat default.nix: %v", err)
}
nixPerm := nixInfo.Mode().Perm()
content, err := os.ReadFile(nixPath)
if err != nil {
return false, "", "", fmt.Errorf("cannot read default.nix: %v", err)
}
re := regexp.MustCompile(`(vendorHash\s*=\s*)"([^"]+)"`)
loc := re.FindSubmatchIndex(content)
if loc == nil {
return false, "", "", fmt.Errorf("vendorHash not found in default.nix")
}
oldHash := string(content[loc[4]:loc[5]])
const sentinel = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
probed := append(append([]byte{}, content[:loc[4]]...), append([]byte(sentinel), content[loc[5]:]...)...)
if err := os.WriteFile(nixPath, probed, nixPerm); err != nil {
return false, "", "", fmt.Errorf("cannot write default.nix: %v", err)
}
restored := false
defer func() {
if !restored {
_ = os.WriteFile(nixPath, content, nixPerm)
}
}()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()View on GitHub (pinned to 71377f2769)
Solutions
- Open default.nix and ensure it contains `vendorHash = "sha256-...";` inside buildGoModule — add or rename the attribute (e.g. change vendorSha256 to vendorHash if on a modern nixpkgs)
- Then re-run `bd fix` so the automated hash repair can find and update it
- If your derivation intentionally doesn't vendor Go modules, skip the nix fix entirely (the file legitimately has no vendorHash)
Example fix
// before (default.nix) vendorSha256 = "sha256-old=="; // after vendorHash = "sha256-old==";
Defensive patterns
Strategy: validation
Validate before calling
grep -qE 'vendorHash\s*=\s*"[^"]+"' default.nix || { echo "default.nix lacks a vendorHash assignment"; exit 1; } Try / catch
out, err := exec.Command("bd", "fix").CombinedOutput()
if err != nil && strings.Contains(string(out), "vendorHash not found in default.nix") {
// add/rename the vendorHash attribute in default.nix, then retry
} Prevention
- Keep the attribute named vendorHash (modern nixpkgs), not vendorSha256
- Always keep vendorHash present with a real or sentinel sha256 value in buildGoModule
- Lint default.nix in CI to assert the vendorHash line exists
When it happens
Trigger: Running `bd fix` against a default.nix that lacks a `vendorHash = "..."` assignment, uses an attribute name other than vendorHash, formats it so the value is not a simple quoted string, or contains only commented-out vendorHash.
Common situations: Projects using the older `vendorSha256` attribute name from pre-23.05 nixpkgs; a mkGoModule/mkVendor derivation using `overrideAttrs` style hashes; hand-edited default.nix that dropped the vendorHash line.
Related errors
- could not parse correct hash from nix output: %s
- nix not found in PATH Manual fix: 1. Edit default.nix:
- dolt version output is unparseable
- embeddeddolt: requires CGO (build with CGO_ENABLED=1)
- errNoCGO
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/30b91bd537cda9b8.
Report an issue: GitHub.