oven-sh/bun · error

Read failed

Error message

Read failed: ${absolutePath}

What it means

Thrown by the readFile wrapper when readFileSync on the resolved absolute path throws (ENOENT, EACCES, etc.). The underlying OS error is chained as `cause`; the message names the exact file that couldn't be read.

Solutions

  1. Check the path exists and is readable
  2. Inspect error.cause for the underlying fs error code
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at scripts/utils.mjs:932 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at scripts/utils.mjs:932

 * @param {object} [options]
 * @param {boolean} [options.cache]
 * @returns {string}
 */
export function readFile(filename, options = {}) {
  const absolutePath = resolve(filename);
  if (options["cache"]) {
    if (cachedFiles?.[absolutePath]) {
      return cachedFiles[absolutePath];
    }
  }

  debugLog("$", "cat", absolutePath);

  let content;
  try {
    content = readFileSync(absolutePath, "utf-8");
  } catch (cause) {
    throw new Error(`Read failed: ${absolutePath}`, { cause });
  }

  if (options["cache"]) {
    cachedFiles ||= {};
    cachedFiles[absolutePath] = content;
  }

  return content;
}

/**
 * @param {string} path
 * @param {number} mode
 */
export function chmod(path, mode) {
  debugLog("$", "chmod", path, mode);
  chmodSync(path, mode);
}

View on GitHub (pinned to 8c5296ac45)