{"record":{"id":"56fd12ddc3c85d27","repo":"NousResearch/hermes-agent","slug":"could-not-create-directory-error-message","errorCode":null,"errorMessage":"Could not create directory: ${error.message}","messagePattern":"Could not create directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/main.ts","lineNumber":11433,"sourceCode":"// settings mount and seeds the value into the picker; writing back persists\n// it via writeDefaultProjectDir so resolveHermesCwd picks it up on the next\n// session spawn (no app restart needed).\nipcMain.handle('hermes:setting:defaultProjectDir:get', async () => ({\n  dir: readDefaultProjectDir(),\n  defaultLabel: app.getPath('home'),\n  resolvedCwd: resolveHermesCwd()\n}))\n\nipcMain.handle('hermes:workspace:sanitize', async (_event, cwd) => sanitizeWorkspaceCwd(cwd))\n\nipcMain.handle('hermes:setting:defaultProjectDir:set', async (_event, dir) => {\n  const next = typeof dir === 'string' && dir.trim() ? dir.trim() : null\n\n  if (next) {\n    try {\n      fs.mkdirSync(next, { recursive: true })\n    } catch (error) {\n      throw new Error(`Could not create directory: ${error.message}`)\n    }\n  }\n\n  writeDefaultProjectDir(next)\n\n  return { dir: next }\n})\n\nipcMain.handle('hermes:setting:defaultProjectDir:pick', async () => {\n  const result = await dialog.showOpenDialog({\n    title: 'Choose default project directory',\n    properties: ['openDirectory', 'createDirectory'],\n    defaultPath: readDefaultProjectDir() || app.getPath('home')\n  })\n\n  if (result.canceled || result.filePaths.length === 0) {\n    return { canceled: true, dir: null }\n  }","sourceCodeStart":11415,"sourceCodeEnd":11451,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/apps/desktop/electron/main.ts#L11415-L11451","documentation":"The 'hermes:setting:defaultProjectDir:set' IPC creates the chosen default project directory with fs.mkdirSync(next, {recursive:true}) before persisting it. If the OS refuses — EACCES, EPERM, ENAMETOOLONG, an existing file at that path, or an invalid path on the platform — the raw mkdir error is wrapped in this message. It is an environment/permissions error, not an app-logic error.","triggerScenarios":"Setting a default project dir pointing to a read-only location, a path owned by another user, a path where a regular file already exists where a directory is expected, or a path with characters invalid on the host OS (e.g. reserved Windows names).","commonSituations":"Choosing a system directory (/proc, C:\\Windows) or a network mount that is disconnected; running with restricted permissions; pasting a path that includes a filename where the directory should be.","solutions":["Read error.message inside — EACCES/EPERM means permissions, EEXIST-with-file means a file blocks the dir, ENOENT on a parent usually means a typo","Pick a directory under the user's home or another user-writable location","Create the directory manually in a terminal to confirm the account can, then set it in the app","On Windows avoid reserved names (CON, PRN) and over-long paths; on network drives ensure the mount is live"],"exampleFix":"# before: default project dir = /srv/projects (root-owned)\n# after\nsudo mkdir -p /srv/projects && sudo chown $USER /srv/projects   # or pick ~/projects","handlingStrategy":"try-catch","validationCode":"// Pre-check writability before persisting\nimport { accessSync, constants } from 'fs'\naccessSync(path.dirname(next), constants.W_OK) // throws early with a clearer signal\nawait ipc.invoke('hermes:setting:defaultProjectDir:set', next)","typeGuard":null,"tryCatchPattern":"try { await ipc.invoke('hermes:setting:defaultProjectDir:set', dir) } catch (e) { if (e instanceof Error && e.message.startsWith('Could not create directory:')) notify(`Pick a writable directory (${e.message})`) else throw e }","preventionTips":["Default the picker to a user-writable location (home dir)","Test-create the directory in the picker flow before saving","Avoid system-owned and disconnected network paths as project dirs"],"tags":["filesystem","permissions","ipc","desktop","configuration"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}