oven-sh/bun · error · Error

page-cache eviction failed for ${path}; results would be war

Error message

page-cache eviction failed for ${path}; results would be warm-cache

What it means

Generic failure raised when the tarball handling pipeline fails without a more specific diagnosis. It is produced by libarchive's ARCHIVE_FAILED/ARCHIVE_FATAL results (mapped via From<bun_libarchive::Error> at src/install/error.rs:411) and by TarballStream when the gzip->tar stream cannot be opened, a header/data block read fails, or archive setup calls return nonzero (src/install/TarballStream.rs:566-637, 960-963).

Source

Thrown at bench/copyfile/fallback-rw-loop.mjs:32

const libc = dlopen("libc.so.6", {
  posix_fadvise: {
    args: [FFIType.i32, FFIType.i64, FFIType.i64, FFIType.i32],
    returns: FFIType.i32,
  },
  fdatasync: { args: [FFIType.i32], returns: FFIType.i32 },
});
const POSIX_FADV_DONTNEED = 4;

function evict(path) {
  let fd;
  try {
    fd = fs.openSync(path, "r+");
  } catch {
    return;
  }
  try {
    if (libc.symbols.fdatasync(fd) !== 0 || libc.symbols.posix_fadvise(fd, 0n, 0n, POSIX_FADV_DONTNEED) !== 0) {
      throw new Error(`page-cache eviction failed for ${path}; results would be warm-cache`);
    }
  } finally {
    fs.closeSync(fd);
  }
}

if (!process.env.BUN_CONFIG_DISABLE_COPY_FILE_RANGE) {
  console.error("note: BUN_CONFIG_DISABLE_COPY_FILE_RANGE not set; fast paths will be used");
}

for (const mb of [1, 64, 512]) {
  const src = join(tmpdir(), `cp-fallback-src-${mb}m.bin`);
  const dst = join(tmpdir(), `cp-fallback-dst-${mb}m.bin`);
  try {
    {
      const chunk = Buffer.allocUnsafe(1048576);
      for (let i = 0; i < chunk.length; i++) chunk[i] = i & 0xff;
      const fd = fs.openSync(src, "w");

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Clear the package cache and refetch: `bun pm cache rm && bun install --force`
  2. Manually fetch the tarball URL (shown in the install log / `npm view <pkg> dist.tarball`) with curl and confirm it is valid gzip+tar
  3. Check `[install] registry` in bunfig.toml and npm config; try registry.npmjs.org directly
  4. If only one package fails, pin a different version of it or install the tarball URL explicitly

Example fix

# before (bunfig.toml)
[install]
registry = "https://internal-mirror.example.com/"

# after
[install]
registry = "https://registry.npmjs.org/"
Defensive patterns

Strategy: retry

Try / catch

const res = Bun.spawnSync(["bun", "install"], { stdout: "pipe", stderr: "pipe" });
if (res.exitCode !== 0 && /Fail/.test(res.stderr.toString())) {
  Bun.spawnSync(["bun", "pm", "cache", "rm"]);
  const retry = Bun.spawnSync(["bun", "install"], { stdout: "inherit", stderr: "inherit" });
  process.exit(retry.exitCode);
}

Prevention

When it happens

Trigger: Running `bun add` / `bun install` where the downloaded body is not a valid gzip-compressed tarball (e.g. an HTML error/login page returned with 200 by a proxy), a truncated/interrupted download, or libarchive failing mid-extraction of a cached tarball.

Common situations: Corporate proxies or npm mirrors serving corrupted artifacts; a custom registry misconfigured in bunfig.toml; a partial tarball left in the cache after a killed install; CDN or network middleboxes mangling the response body.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/2aab5f89c259d287. Report an issue: GitHub.