{"record":{"id":"25804cdb244c2780","repo":"gastownhall/beads","slug":"cannot-stat-default-nix-v","errorCode":null,"errorMessage":"cannot stat default.nix: %v","messagePattern":"cannot stat default\\.nix: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/preflight.go","lineNumber":755,"sourceCode":"\tcmd2 := exec.Command(\"git\", \"diff\", \"--name-only\", \"--cached\", \"--\", \"go.sum\")\n\tout2, _ := cmd2.Output()\n\tif len(strings.TrimSpace(string(out1))) == 0 && len(strings.TrimSpace(string(out2))) == 0 {\n\t\treturn false, \"\", \"\", nil\n\t}\n\n\tif _, err := exec.LookPath(\"nix\"); err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\n\t\t\t\"nix not found in PATH\\n  Manual fix:\\n\" +\n\t\t\t\t\"    1. Edit default.nix: set vendorHash = \\\"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\\\"\\n\" +\n\t\t\t\t\"    2. Run: nix build .#default\\n\" +\n\t\t\t\t\"    3. Copy the 'got:' hash from the error into default.nix\",\n\t\t)\n\t}\n\n\tnixPath := \"default.nix\"\n\tnixInfo, err := os.Stat(nixPath)\n\tif err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"cannot stat default.nix: %v\", err)\n\t}\n\tnixPerm := nixInfo.Mode().Perm()\n\n\tcontent, err := os.ReadFile(nixPath)\n\tif err != nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"cannot read default.nix: %v\", err)\n\t}\n\n\tre := regexp.MustCompile(`(vendorHash\\s*=\\s*)\"([^\"]+)\"`)\n\tloc := re.FindSubmatchIndex(content)\n\tif loc == nil {\n\t\treturn false, \"\", \"\", fmt.Errorf(\"vendorHash not found in default.nix\")\n\t}\n\toldHash := string(content[loc[4]:loc[5]])\n\n\tconst sentinel = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"\n\tprobed := append(append([]byte{}, content[:loc[4]]...), append([]byte(sentinel), content[loc[5]:]...)...)\n\tif err := os.WriteFile(nixPath, probed, nixPerm); err != nil {","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/preflight.go#L737-L773","documentation":"fixNixHash repairs the vendorHash in default.nix by rewriting the file. The first step is os.Stat(\"default.nix\") to capture the file's permissions for the later rewrite; if the file cannot be stat'ed (typically because it does not exist in the current working directory), this error wraps the underlying os error.","triggerScenarios":"Running `bd fix` from a directory where default.nix does not exist (repo root expected), or where the path exists but is unreadable at the directory level (permissions), or a symlink pointing to nothing.","commonSituations":"Executing `bd fix` from a subdirectory instead of the repository root; a broken default.nix symlink; renamed/deleted default.nix after switching build systems.","solutions":["cd to the repository root (where default.nix lives) and re-run `bd fix`","Verify default.nix exists: `ls -la default.nix` — recreate or restore it from git if missing","Check directory permissions if the path exists but stat still fails"],"exampleFix":"// before\n$ cd cmd/bd && bd fix\ncannot stat default.nix: stat default.nix: no such file or directory\n// after\n$ cd /path/to/repo && bd fix","handlingStrategy":"validation","validationCode":"[ -f default.nix ] || { echo \"run from repo root where default.nix lives\"; exit 1; }","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"bd\", \"fix\").CombinedOutput()\nif err != nil && strings.Contains(string(out), \"cannot stat default.nix\") {\n    // cd to repo root or restore default.nix, then retry\n}","preventionTips":["Always run bd fix from the repository root","Keep default.nix tracked in git so it can be restored","Don't rename default.nix without updating tooling that references it"],"tags":["nix","filesystem","file-not-found","cli"],"backgroundTag":"file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}