Fission-AI/OpenSpec · error · Error

Cannot access path

Error message

Cannot access path "${targetPath}": ${error.message}

What it means

Wrapped fs error from the init command's path validation: the stat() call on the resolved target path failed (e.g. ENOENT, EACCES) and the underlying OS message is surfaced to explain why the path could not be inspected.

Solutions

  1. Check the path exists and is spelled correctly
  2. Verify the process has permission to access the path (check ownership/ACLs)
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/cli/index.ts:246 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25). Data as JSON: /api/errors/71ef73d5448af793. Report an issue: GitHub.

Appendix: source

Thrown at src/cli/index.ts:246

  .option('--no-copilot-cloud', 'Skip GitHub Copilot cloud coding-agent files without prompting')
  .action(async (targetPath = '.', options?: { tools?: string; language?: string; force?: boolean; profile?: string; animation?: boolean; copilotCloud?: boolean }) => {
    try {
      // Validate that the path is a valid directory
      const resolvedPath = path.resolve(targetPath);

      try {
        const stats = await fs.stat(resolvedPath);
        if (!stats.isDirectory()) {
          throw new Error(`Path "${targetPath}" is not a directory`);
        }
      } catch (error: any) {
        if (error.code === 'ENOENT') {
          // Directory doesn't exist, but we can create it
          console.log(`Directory "${targetPath}" doesn't exist, it will be created.`);
        } else if (error.message && error.message.includes('not a directory')) {
          throw error;
        } else {
          throw new Error(`Cannot access path "${targetPath}": ${error.message}`);
        }
      }

      const { InitCommand } = await import('../core/init.js');
      const initCommand = new InitCommand({
        tools: options?.tools,
        language: options?.language,
        force: options?.force,
        profile: options?.profile,
        animation: options?.animation,
        copilotCloud: options?.copilotCloud,
      });
      await initCommand.execute(targetPath);
    } catch (error) {
      failWithError(error);
      process.exit(1);
    }
  });

View on GitHub (pinned to 6926ccb18a)