gastownhall/beads · error

nix not found in PATH Manual fix: 1. Edit default.nix:

Error message

nix not found in PATH
  Manual fix:
    1. Edit default.nix: set vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
    2. Run: nix build .#default
    3. Copy the 'got:' hash from the error into default.nix

What it means

During `bd fix` preflight repairs, fixNixHash probes the Nix vendor hash used by default.nix. Before running any nix build it checks that the `nix` executable is on PATH via exec.LookPath; if absent, it returns this error containing step-by-step manual fix instructions instead of attempting the automated fix.

Source

Thrown at cmd/bd/preflight.go:744

	}
	return nil
}

// fixNixHash computes and updates the vendorHash in default.nix.
// It uses a sentinel hash to trigger nix to report the correct hash.
// Returns (fixed, oldHash, newHash, err).
func fixNixHash() (bool, string, string, error) {
	// Check if go.sum has uncommitted changes (same heuristic as runNixHashCheck)
	cmd1 := exec.Command("git", "diff", "--name-only", "HEAD", "--", "go.sum")
	out1, _ := cmd1.Output()
	cmd2 := exec.Command("git", "diff", "--name-only", "--cached", "--", "go.sum")
	out2, _ := cmd2.Output()
	if len(strings.TrimSpace(string(out1))) == 0 && len(strings.TrimSpace(string(out2))) == 0 {
		return false, "", "", nil
	}

	if _, err := exec.LookPath("nix"); err != nil {
		return false, "", "", fmt.Errorf(
			"nix not found in PATH\n  Manual fix:\n" +
				"    1. Edit default.nix: set vendorHash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"\n" +
				"    2. Run: nix build .#default\n" +
				"    3. Copy the 'got:' hash from the error into default.nix",
		)
	}

	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)
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Install Nix (e.g. `sh <(curl -L https://nixos.org/nix/install)`), then re-run `bd fix`
  2. If Nix is installed but not found, add its bin directory to PATH (e.g. `export PATH=$PATH:/nix/var/nix/profiles/per-user/$USER/profile/bin` or source /etc/profile.d/nix.sh)
  3. Follow the manual steps printed in the error: set vendorHash to the all-A sentinel in default.nix, run `nix build .#default`, copy the 'got:' hash back into default.nix

Example fix

// before (error)
nix not found in PATH
// after
export PATH="$PATH:/nix/var/nix/profiles/per-user/$USER/profile/bin"
bd fix
Defensive patterns

Strategy: validation

Validate before calling

command -v nix >/dev/null 2>&1 || { echo "nix required: install https://nixos.org/download"; exit 1; }

Try / catch

out, err := exec.Command("bd", "fix").CombinedOutput()
if err != nil && strings.Contains(string(out), "nix not found in PATH") {
    // install nix or extend PATH, then retry
}

Prevention

When it happens

Trigger: Running `bd fix` (runFixes) on a machine where the Nix package manager is not installed or is not on PATH, while a Nix vendorHash fix is needed (vendorHash mismatch detected).

Common situations: CI container or fresh machine without Nix installed; Nix installed via a multi-user setup whose binaries live outside the current PATH (e.g. /nix/var/nix/profiles/... not linked); running bd inside a sandbox that strips PATH.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/08da375027aef7fd. Report an issue: GitHub.