stablyai/orca · warning · Error

A file or folder named '${basename(targetPath)}' already exi

Error message

A file or folder named '${basename(targetPath)}' already exists in this location

What it means

Thrown by assertNotExists() in the local 'fs:createDir' handler. It lstat()s the target dirPath; if lstat succeeds the path exists and the create is rejected with a friendly collision message naming basename(targetPath). Only ENOENT is allowed through (path free). This is an explicit, non-atomic pre-check (documented as such) that gives a clear message before mkdir is attempted.

Source

Thrown at src/main/ipc/filesystem-mutations.ts:57

    if (code === 'EACCES' || code === 'EPERM') {
      throw new Error(`Permission denied: unable to create '${name}'`)
    }
  }
  throw error
}

/**
 * Ensure `targetPath` does not already exist. Throws if it does.
 *
 * Note: this is a non-atomic check — a concurrent operation could create the
 * path between `lstat` and the caller's next action. Acceptable for a desktop
 * app with low concurrency; `createFile` uses the `wx` flag for an atomic
 * alternative where possible.
 */
async function assertNotExists(targetPath: string): Promise<void> {
  try {
    await lstat(targetPath)
    throw new Error(
      `A file or folder named '${basename(targetPath)}' already exists in this location`
    )
  } catch (error) {
    if (!isENOENT(error)) {
      throw error
    }
  }
}

/**
 * IPC handlers for file/folder creation and renaming.
 * Deletion is handled separately via `fs:deletePath` (shell.trashItem).
 */
export function registerFilesystemMutationHandlers(store: Store): void {
  ipcMain.handle(
    'fs:createFile',
    async (
      _event,

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Choose a different folder name.
  2. Delete or rename the existing file/folder with that name if a folder is genuinely wanted there.
  3. Deconflict the name in the renderer before issuing fs:createDir.

Example fix

// before: await fs.createDir(`${dir}/${name}`) where name exists
// after: pick a unique folder name, or remove the blocker first
await fs.createDir(`${dir}/${name}-folder`)
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check before createDir
import { lstat } from 'node:fs/promises'
async function dirTargetIsFree(p: string): Promise<boolean> {
  try { await lstat(p); return false } catch { return true }
}

Try / catch

try {
  await window.api.fs.createDir({ dirPath })
} catch (e) {
  if (e instanceof Error && /already exists/.test(e.message)) {
    // prompt for a unique folder name and retry
  } else throw e
}

Prevention

When it happens

Trigger: fs:createDir is invoked locally for a dirPath that already exists as a file or directory; lstat resolves the path, so both a same-named file and a same-named folder trigger it.

Common situations: User creates a folder with a name already used in that location; a same-named file blocks the folder creation; a duplicate 'New Folder' action.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/b5e5bd8b32435406. Report an issue: GitHub.