{"record":{"id":"46fb64116c8109d8","repo":"laurent22/joplin","slug":"could-not-create-directory-path","errorCode":null,"errorMessage":"Could not create directory: ${path}","messagePattern":"Could not create directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lib/fs-driver-node.ts","lineNumber":91,"sourceCode":"\t\t\t\t}\n\t\t\t\tthrow this.fsErrorToJsError_(error);\n\t\t\t}\n\t\t}\n\n\t\tthrow lastError;\n\t}\n\n\tpublic exists(path: string) {\n\t\treturn fs.pathExists(path);\n\t}\n\n\tpublic async mkdir(path: string) {\n\t\t// Note that mkdirp() does not throw an error if the directory\n\t\t// could not be created. This would make the synchroniser to\n\t\t// incorrectly try to sync with a non-existing dir:\n\t\t// https://github.com/laurent22/joplin/issues/2117\n\t\tconst r = await fs.mkdirp(path);\n\t\tif (!(await this.exists(path))) throw new Error(`Could not create directory: ${path}`);\n\t\treturn r;\n\t}\n\n\tpublic async stat(path: string): Promise<Stat> {\n\t\ttry {\n\t\t\tconst stat = await fs.stat(path);\n\t\t\treturn {\n\t\t\t\tbirthtime: stat.birthtime,\n\t\t\t\tmtime: stat.mtime,\n\t\t\t\tisDirectory: () => stat.isDirectory(),\n\t\t\t\tpath: path,\n\t\t\t\tsize: stat.size,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error.code === 'ENOENT') return null;\n\t\t\tthrow error;\n\t\t}\n\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/lib/fs-driver-node.ts#L73-L109","documentation":"Thrown by the Node fs driver's mkdir(). The underlying fs-extra mkdirp() does not error if directory creation silently fails, so the driver explicitly re-checks existence afterward. If the dir still isn't there, it throws to prevent the synchronizer from proceeding against a non-existent path (the historical bug laurent22/joplin#2117).","triggerScenarios":"Calling mkdir() where the parent is read-only, the disk is full, the path is invalid, or a file occupies the target path. mkdirp reports success but exists() returns false.","commonSituations":"Insufficient filesystem permissions; read-only mount; path component is a file not a directory; disk full or quota exceeded; network share dropped mid-operation; invalid characters in the path on Windows; antivirus blocking directory creation.","solutions":["Check filesystem permissions on the parent and target path; grant write access.","Confirm no regular file occupies the target path (stat it first).","Free disk space / raise quota on the volume.","On Windows, ensure the path has no invalid characters (<>:\"|?*).","Verify the volume is mounted and writable."],"exampleFix":"// before\nawait shim.fsDriver().mkdir(targetDir);\n// after - diagnose the silent mkdirp failure\nif (await shim.fsDriver().exists(targetDir)) return;\ntry { await shim.fsDriver().mkdir(targetDir); }\ncatch (e) {\n  const parent = path.dirname(targetDir);\n  if (!(await shim.fsDriver().exists(parent))) throw new Error(`Parent missing: ${parent}`);\n  throw e;\n}","handlingStrategy":"validation","validationCode":"if (await shim.fsDriver().exists(targetDir)) return;\nconst parent = path.dirname(targetDir);\nif (!(await shim.fsDriver().exists(parent))) throw new Error(`Parent directory missing: ${parent}`);\nif (!(await shim.fsDriver().isWritable(parent))) throw new Error(`Parent not writable: ${parent}`);","typeGuard":"function isMkdirFailed(e: any): boolean {\n  return e && typeof e.message === 'string' && e.message.startsWith('Could not create directory:');\n}","tryCatchPattern":"try {\n  await shim.fsDriver().mkdir(targetDir);\n} catch (e) {\n  if (isMkdirFailed(e)) {\n    throw new Error(`Cannot create directory ${targetDir}; check permissions, disk space, and that no file blocks the path.`);\n  }\n  throw e;\n}","preventionTips":["Verify write permissions on the parent directory before mkdir.","Ensure no regular file occupies the target path.","Confirm the volume is mounted and has free space.","Avoid invalid path characters on Windows."],"tags":["filesystem","node","mkdir","permissions","config"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}