google-gemini/gemini-cli · error · Error

Directory does not exist

Error message

Directory does not exist: ${absolutePath}

What it means

resolveAndValidateDir was given a workspace directory configuration path that does not exist on disk (existsSync returned false). The expected absolute path is embedded in the message; this fires during directory setup before any stat/type check is made.

Solutions

  1. Create the directory or fix the typo in the configured path
  2. Verify the relative directory is resolved against the intended targetDir
  3. Remove stale directory entries from configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/src/utils/workspaceContext.ts:140 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of google-gemini/gemini-cli@6a466a7e2f (2026-09-16). Data as JSON: /api/errors/5efae7ae5de5ae7f. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/src/utils/workspaceContext.ts:140

    try {
      // Check if it exists
      if (!fs.existsSync(pathToAdd)) {
        return;
      }
      // Resolve symlinks and SFNs canonically
      const resolved = resolveToRealPath(
        path.resolve(this.targetDir, pathToAdd),
      );
      this.readOnlyPaths.add(resolved);
    } catch (e) {
      debugLogger.warn(`Failed to add read-only path ${pathToAdd}:`, e);
    }
  }

  private resolveAndValidateDir(directory: string): string {
    const absolutePath = path.resolve(this.targetDir, directory);

    if (!fs.existsSync(absolutePath)) {
      throw new Error(`Directory does not exist: ${absolutePath}`);
    }
    const stats = fs.statSync(absolutePath);
    if (!stats.isDirectory()) {
      throw new Error(`Path is not a directory: ${absolutePath}`);
    }

    // Resolve workspace directory canonically (supporting Windows SFNs)
    return resolveToRealPath(absolutePath);
  }

  /**
   * Gets a copy of all workspace directories.
   * @returns Array of absolute directory paths
   */
  getDirectories(): readonly string[] {
    return Array.from(this.directories);
  }

View on GitHub (pinned to 6a466a7e2f)