Fission-AI/OpenSpec · error

Cannot create openspec/config.yaml for --language

Error message

Cannot create openspec/config.yaml for --language${reason}

What it means

Pre-flight guard for --language: no config file exists, and creating openspec/config.yaml was rejected by the project-artifact path assertion (the config path would escape or violate the project artifact rules). The wrapped reason is appended to the message.

Solutions

  1. Check the reported reason and ensure openspec/ sits inside the project root
  2. Remove symlinks or path constructs that make the config path non-artifact
  3. Retry init with --language after the path is valid
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/core/init.ts:1068 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/79f619140be66ce8. Report an issue: GitHub.

Appendix: source

Thrown at src/core/init.ts:1068

    return formatLanguageContext(this.language);
  }

  private async assertLanguageCanBeApplied(
    projectPath: string,
    openspecPath: string
  ): Promise<void> {
    const languageContext = this.languageContext();
    if (!languageContext) return;

    const configPath = path.join(openspecPath, 'config.yaml');
    const hasConfig = fs.existsSync(configPath) ||
      fs.existsSync(path.join(openspecPath, 'config.yml'));
    if (!hasConfig) {
      try {
        FileSystemUtils.assertProjectArtifactPath(projectPath, configPath);
      } catch (error) {
        const reason = error instanceof Error ? `: ${error.message}` : '';
        throw new Error(`Cannot create openspec/config.yaml for --language${reason}`);
      }
      if (!(await FileSystemUtils.canWriteFile(configPath))) {
        throw new Error(
          'Cannot create openspec/config.yaml for --language: the destination is not writable.'
        );
      }
      return;
    }

    const existingContext = readProjectConfig(projectPath)?.context;
    if (existingContext?.includes(languageContext)) return;

    throw new Error(
      '--language does not overwrite an existing OpenSpec config. ' +
      'Add the language instruction to its context field instead.'
    );
  }

View on GitHub (pinned to 6926ccb18a)