{"record":{"id":"4e3de304df33ffb4","repo":"Fission-AI/OpenSpec","slug":"store-git-init-failed","errorCode":"store_git_init_failed","errorMessage":"Failed to initialize Git repository: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to initialize Git repository: (.+?)","errorType":"error_code","errorClass":"StoreError","httpStatus":null,"severity":"error","filePath":"src/core/store/git.ts","lineNumber":44,"sourceCode":"\nexport async function isGitRepositoryAtRoot(storeRoot: string): Promise<boolean> {\n  try {\n    const stat = await fs.stat(path.join(storeRoot, '.git'));\n    return stat.isDirectory() || stat.isFile();\n  } catch {\n    return false;\n  }\n}\n\nexport async function initGitRepository(storeRoot: string): Promise<boolean> {\n  if (await isGitRepositoryAtRoot(storeRoot)) {\n    return false;\n  }\n\n  try {\n    await execFileAsync('git', ['init'], { cwd: storeRoot });\n  } catch (error) {\n    throw new StoreError(\n      `Failed to initialize Git repository: ${error instanceof Error ? error.message : String(error)}`,\n      'store_git_init_failed',\n      {\n        target: 'store.git',\n        fix: 'Install Git or rerun setup with --no-init-git.',\n      }\n    );\n  }\n\n  return true;\n}\n\n/**\n * `git var` resolves identity exactly as `git commit` would (config, env vars,\n * auto-detection), so this fails precisely when the initial commit would.\n */\nexport async function assertGitCommitIdentity(probeCwd: string): Promise<void> {\n  for (const identVar of ['GIT_COMMITTER_IDENT', 'GIT_AUTHOR_IDENT']) {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/store/git.ts#L26-L62","documentation":"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.","triggerScenarios":"Thrown at src/core/store/git.ts:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the embedded git error for the underlying cause (permissions, disk, bad args)","Verify git is installed and on PATH for the running environment","Initialize the repository manually with 'git init' to surface the error interactively, then rerun setup"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","contentChangedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}