Fission-AI/OpenSpec · error · StoreError

store_git_init_failed

store_git_init_failed

Error message

Failed to initialize Git repository: ${error instanceof Error ? error.message : String(error)}

What it means

StoreError wrapping a failed 'git init' subprocess in initGitRepository: the exec of git itself errored (not merely a non-zero exit — stderr/stdout is embedded). Only reached when the directory is not already a git repository; the wrapped message carries git's own diagnostics.

Solutions

  1. Check the embedded git error for the underlying cause (permissions, disk, bad args)
  2. Verify git is installed and on PATH for the running environment
  3. Initialize the repository manually with 'git init' to surface the error interactively, then rerun setup
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/core/store/git.ts:44 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/4e3de304df33ffb4. Report an issue: GitHub.

Appendix: source

Thrown at src/core/store/git.ts:44

export async function isGitRepositoryAtRoot(storeRoot: string): Promise<boolean> {
  try {
    const stat = await fs.stat(path.join(storeRoot, '.git'));
    return stat.isDirectory() || stat.isFile();
  } catch {
    return false;
  }
}

export async function initGitRepository(storeRoot: string): Promise<boolean> {
  if (await isGitRepositoryAtRoot(storeRoot)) {
    return false;
  }

  try {
    await execFileAsync('git', ['init'], { cwd: storeRoot });
  } catch (error) {
    throw new StoreError(
      `Failed to initialize Git repository: ${error instanceof Error ? error.message : String(error)}`,
      'store_git_init_failed',
      {
        target: 'store.git',
        fix: 'Install Git or rerun setup with --no-init-git.',
      }
    );
  }

  return true;
}

/**
 * `git var` resolves identity exactly as `git commit` would (config, env vars,
 * auto-detection), so this fails precisely when the initial commit would.
 */
export async function assertGitCommitIdentity(probeCwd: string): Promise<void> {
  for (const identVar of ['GIT_COMMITTER_IDENT', 'GIT_AUTHOR_IDENT']) {

View on GitHub (pinned to 6926ccb18a)