{"record":{"id":"2b4aa2b24bfaa92d","repo":"stablyai/orca","slug":"permission-denied-unable-to-create-name","errorCode":null,"errorMessage":"Permission denied: unable to create '${name}'","messagePattern":"Permission denied: unable to create '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/filesystem-mutations.ts","lineNumber":40,"sourceCode":"import { importExternalPathsSsh } from './filesystem-import-ssh'\nimport type { SshMutationExpectation } from '../../shared/ssh-types'\nimport { assertSshMutationExpectation } from '../ssh/ssh-connection-generation'\nimport { renameLocalPathSerializedByDestination } from '../destination-serialized-local-rename'\n\n/**\n * Re-throw filesystem errors with user-friendly messages.\n * The `wx` flag on writeFile throws a raw EEXIST with no helpful message,\n * so we catch it here and provide context the renderer can display directly.\n */\nfunction rethrowWithUserMessage(error: unknown, targetPath: string): never {\n  const name = basename(targetPath)\n  if (error instanceof Error && 'code' in error) {\n    const code = (error as NodeJS.ErrnoException).code\n    if (code === 'EEXIST') {\n      throw new Error(`A file or folder named '${name}' already exists in this location`)\n    }\n    if (code === 'EACCES' || code === 'EPERM') {\n      throw new Error(`Permission denied: unable to create '${name}'`)\n    }\n  }\n  throw error\n}\n\n/**\n * Ensure `targetPath` does not already exist. Throws if it does.\n *\n * Note: this is a non-atomic check — a concurrent operation could create the\n * path between `lstat` and the caller's next action. Acceptable for a desktop\n * app with low concurrency; `createFile` uses the `wx` flag for an atomic\n * alternative where possible.\n */\nasync function assertNotExists(targetPath: string): Promise<void> {\n  try {\n    await lstat(targetPath)\n    throw new Error(\n      `A file or folder named '${basename(targetPath)}' already exists in this location`","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem-mutations.ts#L22-L58","documentation":"Thrown by rethrowWithUserMessage() when the createFile write fails with errno code EACCES or EPERM. These codes mean the process lacks permission to create/write the target (or to traverse its parent directory). The message names basename(targetPath) so the renderer can surface a friendly 'Permission denied' notice.","triggerScenarios":"fs:createFile is invoked for a path whose parent directory is not writable by the Orca process, or where an existing same-named entry is not replaceable (and 'wx' surfaces EACCES/EPERM), or on a read-only/protected filesystem.","commonSituations":"Workspace root inside a system/protected directory (e.g. /usr, a read-only mount); file flagged immutable; parent directory owned by another user with no write bit; SMB/NFS mount mounted read-only or with wrong uid.","solutions":["Create the file in a writable location (move the workspace or target dir onto a writable volume).","Fix permissions on the parent directory so the Orca process can write (chmod/chown).","Remount the network volume read-write, or with the correct user mapping.","Remove the immutable flag on the target if set (chflags/chattr)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the parent dir is writable by this process before createFile\nimport { access, constants } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nasync function parentIsWritable(p: string): Promise<boolean> {\n  try { await access(dirname(p), constants.W_OK); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await window.api.fs.createFile({ filePath })\n} catch (e) {\n  if (e instanceof Error && /Permission denied/.test(e.message)) {\n    // pick a writable location or fix parent permissions, then retry\n  } else throw e\n}","preventionTips":["Create files under workspace roots that the Orca process can write to.","Fix parent directory ownership/permissions (chmod/chown) before retries.","Avoid read-only or incorrectly mounted network volumes for the workspace."],"tags":["filesystem","permissions","errno","create"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}