oven-sh/bun · error · bun_install::Error
AccessDenied
Error message
AccessDenied
What it means
Installer error for permission-denied filesystem outcomes (the EACCES family): bun could not read or write a path under node_modules, the global install directory, or the cache because the OS refused it.
Source
Thrown at src/install/error.rs:5
#[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")]View on GitHub (pinned to 8c5296ac45)
Solutions
- Check ownership of the failing path: ls -la node_modules and the cache dir
- Reclaim it: sudo chown -R $(id -u):$(id -g) node_modules (or delete and reinstall)
- Do not mix sudo-installed package managers with bun on the same node_modules
- Point BUN_INSTALL and the cache to a user-writable location
Example fix
# before sudo npm install # creates root-owned node_modules bun install # -> AccessDenied # after sudo rm -rf node_modules bun install
Defensive patterns
Strategy: validation
Validate before calling
import { accessSync, constants } from "node:fs";
try {
accessSync("node_modules", constants.W_OK);
} catch {
console.error("node_modules is not writable by this user; fix ownership first");
process.exit(1);
} Prevention
- One package manager, one user, one node_modules
- Set BUN_INSTALL per-user in the shell profile
- CI images should chown project dirs to the runtime user
When it happens
Trigger: node_modules or the global bin dir owned by another user (mixing sudo npm with bun install); a read-only bind mount or Docker volume; a cache dir placed under a protected path; restrictive directory permissions.
Common situations: Previously ran npm/sudo as root so node_modules is root-owned; CI container runs as non-root but files were created by root; BUN_INSTALL pointing into /usr/local; shared machines with multiple users.
Related errors
- not implemented right
- blob.text() failed
- Your package manager doesn't seem to support bun. To use bun
- FileNotFound
- NotDir
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/7544d145a088abc8.
Report an issue: GitHub.