{"record":{"id":"4e8bf3328c940a6a","repo":"oven-sh/bun","slug":"filenotfound-4e8bf3","errorCode":null,"errorMessage":"FileNotFound","messagePattern":"FileNotFound","errorType":"error_code","errorClass":"bun_install::Error","httpStatus":null,"severity":"error","filePath":"src/install/error.rs","lineNumber":3,"sourceCode":"#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]\npub enum Error {\n    #[error(\"FileNotFound\")]\n    FileNotFound,\n    #[error(\"AccessDenied\")]\n    AccessDenied,\n    #[error(\"NotDir\")]\n    NotDir,\n    #[error(\"NameTooLong\")]\n    NameTooLong,\n    #[error(\"SymLinkLoop\")]\n    SymLinkLoop,\n    #[error(\"SystemFdQuotaExceeded\")]\n    SystemFdQuotaExceeded,\n    #[error(\"SystemResources\")]\n    SystemResources,\n    #[error(\"DeviceBusy\")]\n    DeviceBusy,\n    #[error(\"TarballHTTP400\")]\n    TarballHTTP400,\n    #[error(\"TarballHTTP401\")]","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/install/error.rs#L1-L21","documentation":"Unit variant of bun_install::Error (the installer's thiserror enum) surfaced as \"FileNotFound\" when an install-time filesystem path that must exist does not — the ENOENT-equivalent outcome of the installer's file operations such as reading package.json, the lockfile, cached tarballs, or node_modules paths.","triggerScenarios":"`bun install` run in a directory without package.json; a lockfile/cache entry pointing at a tarball deleted from the cache; lifecycle scripts or external tools moving/deleting files mid-install.","commonSituations":"Wrong cwd in CI or Docker layers; BUN_INSTALL_CACHE_DIR retargeted or emptied; partial node_modules left by a crashed earlier install; scripts pruning files during install.","solutions":["Run bun install from the directory containing package.json","Remove the stale lockfile and rebuild: rm bun.lock && rm -rf node_modules && bun install","Verify BUN_INSTALL_CACHE_DIR points at an existing directory","Re-run once to rule out a concurrent process deleting files mid-install"],"exampleFix":"# before\ncd packages/web && bun install   # no package.json here\n\n# after\ncd /repo && bun install           # root/workspace with package.json","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\n\nif (!existsSync(\"package.json\")) {\n  console.error(\"no package.json in\", process.cwd());\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"const p = Bun.spawnSync([\"bun\", \"install\"]);\nif (p.stderr.toString().includes(\"FileNotFound\")) {\n  // re-check cwd, lockfile, and cache dir before retrying\n}","preventionTips":["Assert cwd contains package.json before install in CI","Do not delete cache internals manually","Configure the cache dir in one place"],"tags":["install","filesystem","enoent"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}