google-gemini/gemini-cli · error

The path "${trimmedPath}" does not exist.

Error message

The path "${trimmedPath}" does not exist.

What it means

When fs.stat() throws an ENOENT error inside validateWorkspacePath(), the catch block intercepts it and re-throws with this user-friendly message. The path passed the null-byte and containment checks but does not exist on disk.

Source

Thrown at packages/a2a-server/src/utils/path_utils.ts:58

    // Check if the resolved path is within the allowed root directory
    if (
      canonicalWorkspacePath !== canonicalAllowedRoot &&
      !isSubpath(canonicalAllowedRoot, canonicalWorkspacePath)
    ) {
      throw new Error(
        `Security violation: The path "${trimmedPath}" is outside the allowed root directory.`,
      );
    }

    const stats = await fs.promises.stat(canonicalWorkspacePath);
    if (!stats.isDirectory()) {
      throw new Error(`The path "${trimmedPath}" is not a directory.`);
    }

    return canonicalWorkspacePath;
  } catch (e) {
    if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
      throw new Error(`The path "${trimmedPath}" does not exist.`);
    }
    throw e; // Re-throw other errors
  }
}

View on GitHub (pinned to 5024443c72)

Solutions

  1. Create the directory (fs.mkdir or fse.ensureDir) before calling validateWorkspacePath.
  2. Verify the path spelling and ensure it matches the actual filesystem layout.
  3. Ensure the process CWD matches expectations when using relative allowedRoot defaults.

Example fix

// before
const dir = await validateWorkspacePath('./myworkspace'); // throws if not on disk

// after
import { ensureDir } from 'fs-extra';
await ensureDir('./myworkspace');
const dir = await validateWorkspacePath('./myworkspace');
Defensive patterns

Strategy: try-catch

Validate before calling

import fse from 'fs-extra';

async function ensureWorkspaceExists(path: string): Promise<void> {
  await fse.ensureDir(path);
}

// Before validation:
await ensureWorkspaceExists(workspacePath);
const safe = await validateWorkspacePath(workspacePath);

Try / catch

try {
  const dir = await validateWorkspacePath(candidate);
} catch (e) {
  if (e instanceof Error && e.message.includes('does not exist')) {
    await fse.ensureDir(candidate);
    // retry or handle
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling validateWorkspacePath() with a well-formed path within the allowed root that simply doesn't exist on the filesystem — e.g., a directory that hasn't been created yet or was deleted.

Common situations: Typo in path; directory not yet created; wrong working directory; race condition where the directory was removed between the containment check and the stat call.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/e67649709e3aaddc. Report an issue: GitHub.