oven-sh/bun · error · bun_install::Error

NameTooLong

Error message

NameTooLong

What it means

Installer error matching ENAMETOOLONG: a path or path component written during install exceeds the OS limit (255 bytes per component on POSIX, PATH_MAX overall, MAX_PATH on Windows), typically deep inside node_modules, bin links, or the cache layout.

Source

Thrown at src/install/error.rs:9

#[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")]
    TarballHTTP401,
    #[error("TarballHTTP402")]
    TarballHTTP402,
    #[error("TarballHTTP403")]
    TarballHTTP403,
    #[error("TarballHTTP404")]

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Move/clone the project closer to the filesystem root to shorten the absolute path
  2. Set BUN_INSTALL_CACHE_DIR to a short path (e.g. /c/bun-cache or C:\\bc)
  3. On Windows, enable long paths (LongPathsEnabled registry + git core.longpaths) or shorten the checkout dir
  4. Bump the offending dependency if a transitive chain produces over-long names

Example fix

# before
/home/user/very/long/deeply/nested/path/to/repo && bun install

# after
mv repo ~/r && cd ~/r && bun install
Defensive patterns

Strategy: validation

Validate before calling

const cwd = process.cwd();
const budget = process.platform === "win32" ? 240 : 4000;
if (cwd.length + "/node_modules/".length + 255 > budget) {
  console.error("project path too deep; move the checkout closer to the root");
  process.exit(1);
}

Prevention

When it happens

Trigger: Deeply nested dependency chains with long scoped names; project checked out under a very long absolute path; cache dir configured far down the tree; Windows 260-char MAX_PATH exceeded.

Common situations: Monorepos under long user directories (especially on Windows); long generated package names; CI agents with deep workspace paths; nested workspace roots.

Related errors


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