bmad-code-org/BMAD-METHOD · error · Error
${label}: cannot create directory: ${dirPath} (${error.messa
Error message
${label}: cannot create directory: ${dirPath} (${error.message}) What it means
Catch-all thrown by ensureWritableDir when fs.ensureDir fails with an error code other than EACCES or ENOSPC. Includes the underlying error message so the root cause is visible.
Source
Thrown at tools/installer/core/install-paths.js:122
}
}
async function ensureWritableDir(dirPath, label) {
const stat = await fs.stat(dirPath).catch(() => null);
if (stat && !stat.isDirectory()) {
throw new Error(`${label} exists but is not a directory: ${dirPath}`);
}
try {
await fs.ensureDir(dirPath);
} catch (error) {
if (error.code === 'EACCES') {
throw new Error(`${label}: permission denied creating directory: ${dirPath}`);
}
if (error.code === 'ENOSPC') {
throw new Error(`${label}: no space left on device: ${dirPath}`);
}
throw new Error(`${label}: cannot create directory: ${dirPath} (${error.message})`);
}
try {
await fs.access(dirPath, fs.constants.R_OK | fs.constants.W_OK);
} catch {
throw new Error(`${label} is not writable: ${dirPath}`);
}
}
module.exports = { InstallPaths };
View on GitHub (pinned to b70486b9bd)
Solutions
- Read the parenthesized underlying message to identify the OS error code.
- EROFS: remount read-write or pick a writable target.
- EMFILE/ENFILE: raise ulimits or reduce concurrency.
- EIO/hardware: check disk health; pick a different target.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await ensureWritableDir(dirPath, label);
} catch (error) {
const m = error.message.match(/cannot create directory: .*\((.*)\)/);
if (m) { /* m[1] is the underlying OS error message; branch on it */ }
throw error;
} Prevention
- Read the underlying error in parentheses to classify the OS failure.
- For EROFS, relocate the target off the read-only filesystem.
When it happens
Trigger: ensureDir raises an unexpected error during recursive mkdir, e.g. EROFS (read-only filesystem), EMFILE (too many open files), EIO, or a path that is too long.
Common situations: Installing onto a read-only filesystem, hitting OS resource limits, hardware/IO errors, or path-length limits on Windows.
Related errors
- ${label} does not exist: ${dirPath}
- ${label} is not a directory: ${dirPath}
- ${label} is not readable: ${dirPath}
- ${label} does not exist: ${filePath}
- ${label} is not a file: ${filePath}
AI-assisted analysis of bmad-code-org/BMAD-METHOD@b70486b9bd (2026-08-13).
Data as JSON: /api/errors/de43578e38a7e857.
Report an issue: GitHub.