{"record":{"id":"7544d145a088abc8","repo":"oven-sh/bun","slug":"accessdenied-7544d1","errorCode":null,"errorMessage":"AccessDenied","messagePattern":"AccessDenied","errorType":"error_code","errorClass":"bun_install::Error","httpStatus":null,"severity":"error","filePath":"src/install/error.rs","lineNumber":5,"sourceCode":"#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]\npub enum Error {\n    #[error(\"FileNotFound\")]\n    FileNotFound,\n    #[error(\"AccessDenied\")]\n    AccessDenied,\n    #[error(\"NotDir\")]\n    NotDir,\n    #[error(\"NameTooLong\")]\n    NameTooLong,\n    #[error(\"SymLinkLoop\")]\n    SymLinkLoop,\n    #[error(\"SystemFdQuotaExceeded\")]\n    SystemFdQuotaExceeded,\n    #[error(\"SystemResources\")]\n    SystemResources,\n    #[error(\"DeviceBusy\")]\n    DeviceBusy,\n    #[error(\"TarballHTTP400\")]\n    TarballHTTP400,\n    #[error(\"TarballHTTP401\")]\n    TarballHTTP401,\n    #[error(\"TarballHTTP402\")]","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/install/error.rs#L1-L23","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nsudo npm install   # creates root-owned node_modules\nbun install        # -> AccessDenied\n\n# after\nsudo rm -rf node_modules\nbun install","handlingStrategy":"validation","validationCode":"import { accessSync, constants } from \"node:fs\";\n\ntry {\n  accessSync(\"node_modules\", constants.W_OK);\n} catch {\n  console.error(\"node_modules is not writable by this user; fix ownership first\");\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["install","permissions","filesystem","eacces"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}