stablyai/orca · warning · Error

A file or folder named '${name}' already exists in this loca

Error message

A file or folder named '${name}' already exists in this location

What it means

Thrown by rethrowWithUserMessage() when a createFile write (writeFile with flag 'wx') fails with errno code EEXIST. The 'wx' flag atomically refuses to overwrite, so EEXIST means the target path already existed at write time. rethrowWithUserMessage swaps the raw errno for a renderer-displayable message naming basename(targetPath).

Source

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

import { authorizeExternalPath, resolveAuthorizedPath, isENOENT } from './filesystem-auth'
import { requireSshFilesystemProvider } from '../providers/ssh-filesystem-dispatch'
import { resolveLocalDroppedPathsForAgent } from './dropped-path-resolution'
import { importExternalPathsSsh } from './filesystem-import-ssh'
import type { SshMutationExpectation } from '../../shared/ssh-types'
import { assertSshMutationExpectation } from '../ssh/ssh-connection-generation'
import { renameLocalPathSerializedByDestination } from '../destination-serialized-local-rename'

/**
 * Re-throw filesystem errors with user-friendly messages.
 * The `wx` flag on writeFile throws a raw EEXIST with no helpful message,
 * so we catch it here and provide context the renderer can display directly.
 */
function rethrowWithUserMessage(error: unknown, targetPath: string): never {
  const name = basename(targetPath)
  if (error instanceof Error && 'code' in error) {
    const code = (error as NodeJS.ErrnoException).code
    if (code === 'EEXIST') {
      throw new Error(`A file or folder named '${name}' already exists in this location`)
    }
    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 {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Choose a different file name in the create action.
  2. Delete or rename the existing entry first if overwrite is intended (note: createFile intentionally refuses to overwrite).
  3. Deconflict the name in the renderer before issuing fs:createFile.

Example fix

// before: await fs.createFile(`${dir}/${name}`) where name exists
// after
if (await fs.pathExists(`${dir}/${name}`)) {
  name = await fs.uniqueName(dir, name)
}
await fs.createFile(`${dir}/${name}`)
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check the path is free before createFile (atomic 'wx' is still authoritative)
import { lstat } from 'node:fs/promises'
async function pathIsFree(p: string): Promise<boolean> {
  try { await lstat(p); return false } catch { return true }
}

Try / catch

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

Prevention

When it happens

Trigger: fs:createFile is invoked (locally) for a filePath that already exists as a file or folder; the race window in assertNotExists-style checks is closed by the atomic 'wx' flag, so this fires on a genuine pre-existing path or a concurrent creation that beat this call.

Common situations: User clicked 'New File' with a name already present in the folder; a duplicate creation attempt; two concurrent createFile calls for the same path; a folder with the same name as the file being created.

Related errors


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