{"record":{"id":"36032a6da9cb4f57","repo":"coleam00/Archon","slug":"repopath-is-not-a-valid-git-repository-ensure","errorCode":null,"errorMessage":"${repoPath} is not a valid git repository. Ensure the workspace was cloned correctly.","messagePattern":"(.+?) is not a valid git repository\\. Ensure the workspace was cloned correctly\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/isolation/src/providers/worktree.ts","lineNumber":961,"sourceCode":"      const { branch } = await syncWorkspace(\n        repoPath,\n        configuredBaseBranch ? toBranchName(configuredBaseBranch) : undefined,\n        { mode: isManagedClone ? 'reset' : 'fast-forward', remote }\n      );\n      getLog().debug({ repoPath, branch, remote }, 'workspace_synced');\n      return branch;\n    } catch (error) {\n      const err = error as Error & { code?: string };\n      const errorMessage = err.message.toLowerCase();\n\n      // Fatal errors - throw to prevent confusing downstream failures\n      if (err.code === 'EACCES' || errorMessage.includes('permission denied')) {\n        throw new Error(\n          `Permission denied accessing repository at ${repoPath}. ` +\n            'Check file permissions and try again.'\n        );\n      } else if (errorMessage.includes('not a git repository')) {\n        throw new Error(\n          `${repoPath} is not a valid git repository. ` +\n            'Ensure the workspace was cloned correctly.'\n        );\n      } else if (errorMessage.includes('configured base branch')) {\n        // Configured branch errors are fatal - user needs to fix their config\n        throw err;\n      } else {\n        // Network errors, timeouts — cannot guarantee correct start-point\n        throw new Error(\n          `Failed to fetch base branch from '${remote}': ${err.message}. ` +\n            'Check your network connection and remote configuration.'\n        );\n      }\n    }\n  }\n\n  /**\n   * Copy git-ignored files to worktree based on repo config.","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/isolation/src/providers/worktree.ts#L943-L979","documentation":"During pre-create workspace sync, an error whose message contains 'not a git repository' is translated into this dedicated error, because branching a worktree from a non-repo directory would produce meaningless results. It signals the workspace checkout itself is missing or broken.","triggerScenarios":"syncWorkspaceBeforeCreate (via WorktreeProvider.create) invokes git in repoPath and git exits with 'fatal: not a git repository (or any of the parent directories)'.","commonSituations":"The recorded workspace path points at a deleted or renamed directory; a clone failed or was interrupted leaving no `.git`; the configured canonicalRepoPath points at a subdirectory instead of the repo root; `.git` was removed accidentally.","solutions":["Verify repoPath contains a `.git` directory (`ls -a <repoPath>/.git`); if not, re-clone the workspace","Correct the repo path in your Archon configuration if it points to the wrong directory","Re-run the Archon workspace setup/clone step to rebuild a corrupted checkout","Check you didn't delete `.git` (e.g. an overzealous clean script) and restore it from the remote"],"exampleFix":"# before\n/path/to/workspace  # no .git, only source files\n# after\nrm -rf /path/to/workspace && archon setup  # or: git clone <url> /path/to/workspace","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nconst execFileAsync = promisify(execFile);\nexport async function assertIsGitRepo(repoPath: string): Promise<void> {\n  if (!existsSync(`${repoPath}/.git`)) {\n    throw new Error(`${repoPath} has no .git; re-clone or fix the configured path`);\n  }\n  await execFileAsync('git', ['-C', repoPath, 'rev-parse', '--git-dir']);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const env = await provider.create(request);\n} catch (e) {\n  if ((e as Error).message.includes('is not a valid git repository')) {\n    console.error('Re-clone the workspace or correct canonicalRepoPath before retrying.');\n  }\n  throw e;\n}","preventionTips":["Verify the workspace exists and has `.git` before pointing Archon at it","Point config at the repo root, not a subdirectory","Avoid cleanup scripts that delete `.git`","Re-run workspace setup after any interrupted clone"],"tags":["git","workspace","invalid-repo","sync"],"backgroundTag":"not-a-git-repository","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}