oven-sh/bun · error · bun_install::Error
FileNotFound
Error message
FileNotFound
What it means
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.
Source
Thrown at src/install/error.rs:3
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error("FileNotFound")]
FileNotFound,
#[error("AccessDenied")]
AccessDenied,
#[error("NotDir")]
NotDir,
#[error("NameTooLong")]
NameTooLong,
#[error("SymLinkLoop")]
SymLinkLoop,
#[error("SystemFdQuotaExceeded")]
SystemFdQuotaExceeded,
#[error("SystemResources")]
SystemResources,
#[error("DeviceBusy")]
DeviceBusy,
#[error("TarballHTTP400")]
TarballHTTP400,
#[error("TarballHTTP401")]View on GitHub (pinned to 8c5296ac45)
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
Example fix
# before cd packages/web && bun install # no package.json here # after cd /repo && bun install # root/workspace with package.json
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from "node:fs";
if (!existsSync("package.json")) {
console.error("no package.json in", process.cwd());
process.exit(1);
} Try / catch
const p = Bun.spawnSync(["bun", "install"]);
if (p.stderr.toString().includes("FileNotFound")) {
// re-check cwd, lockfile, and cache dir before retrying
} Prevention
- Assert cwd contains package.json before install in CI
- Do not delete cache internals manually
- Configure the cache dir in one place
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- not implemented right
- blob.text() failed
- Your package manager doesn't seem to support bun. To use bun
- AccessDenied
- NotDir
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/4e8bf3328c940a6a.
Report an issue: GitHub.