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

DeviceBusy

Error message

DeviceBusy

What it means

Installer error for EBUSY: a file or resource bun needs is held by another process. On Windows this is the classic file-lock collision during extraction/linking; on Linux it maps to mounts or devices in use.

Source

Thrown at src/install/error.rs:17

#[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")]
    TarballHTTP404,
    #[error("TarballHTTP4xx")]
    TarballHTTP4xx,
    #[error("TarballHTTP5xx")]
    TarballHTTP5xx,
    #[error("TarballFailedToExtract")]
    TarballFailedToExtract,
    #[error("TarballFailedToDownload")]

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Stop the process holding the files (dev server, watcher) and rerun bun install
  2. Exclude node_modules from antivirus real-time scans and sync clients
  3. Ensure only one install runs at a time per project
  4. Retry after a short delay once the lock is released

Example fix

# before (two terminals)
bun run dev    # watcher holds node_modules
bun install    # -> DeviceBusy

# after
# stop the dev server first, then
bun install && bun run dev
Defensive patterns

Strategy: retry

Try / catch

async function installWithRetry() {
  for (let i = 0; i < 3; i++) {
    const p = Bun.spawnSync(["bun", "install"]);
    if (p.exitCode === 0) return;
    if (!p.stderr.toString().includes("DeviceBusy")) process.exit(p.exitCode ?? 1);
    await Bun.sleep(2000); // lock holder often releases within seconds
  }
}

Prevention

When it happens

Trigger: A dev server, file watcher, editor indexer, or antivirus holds files inside node_modules while bun rewrites them; Windows locks bin shims or native addon files during rename/link; two installs racing on one project.

Common situations: Running bun install while a hot-reload dev server serves from the same tree; OneDrive/Dropbox/Defender scanning node_modules in real time; parallel CI jobs sharing a workspace.

Related errors


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