{"record":{"id":"d3009c9bb39bb722","repo":"facebook/docusaurus","slug":"couldn-t-find-the-git-superproject-root-directory-d3009c","errorCode":null,"errorMessage":"Couldn't find the git superproject root directory\nFailure while running ${logger.code('git rev-parse --show-superproject-working-tree')} from cwd=${logger.path(cwd)}\nThe command returned exit code ${logger.code(result.exitCode)}: ${logger.subdue(result.stderr)}","messagePattern":"Couldn't find the git superproject root directory\nFailure while running (.+?) from cwd=(.+?)\nThe command returned exit code (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-utils/src/vcs/gitUtils.ts","lineNumber":338,"sourceCode":"  };\n\n  const result = await execa(\n    'git',\n    ['rev-parse', '--show-superproject-working-tree'],\n    {\n      cwd,\n    },\n  ).catch((error) => {\n    // We enter this rejection when cwd is not a dir for example\n    throw new Error(\n      `${createErrorMessageBase()}\nThe command executed throws an error: ${error.message}`,\n      {cause: error},\n    );\n  });\n\n  if (result.exitCode !== 0) {\n    throw new Error(\n      `${createErrorMessageBase()}\nThe command returned exit code ${logger.code(result.exitCode)}: ${logger.subdue(\n        result.stderr,\n      )}`,\n    );\n  }\n\n  const output = result.stdout.trim();\n  // this command only works when inside submodules\n  // otherwise it doesn't return anything when we are inside the main repo\n  if (output) {\n    return fs.realpath.native(output);\n  }\n  return getGitRepoRoot(cwd);\n}\n\n// See https://git-scm.com/book/en/v2/Git-Tools-Submodules\nexport async function getGitSubmodulePaths(cwd: string): Promise<string[]> {","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-utils/src/vcs/gitUtils.ts#L320-L356","documentation":"Thrown by getGitSuperProjectRoot when `git rev-parse --show-superproject-working-tree` runs but returns a non-zero exit code. Note: this command legitimately returns non-zero in a non-submodule repo; Docusaurus treats any non-zero as fatal here, so the practical trigger is a git state where the probe exits non-zero unexpectedly (e.g. inside a broken submodule, detached gitdir, or git older than the flag).","triggerScenarios":"Running getGitAllRepoRoots inside a submodule whose gitdir is broken, with a git version predating --show-superproject-working-tree (git < 2.13), or in a repo where the worktree is corrupted.","commonSituations":"Old git in CI images, partially-initialized submodules (`git submodule update` not run), or a worktree created with `git worktree add` whose links were later removed.","solutions":["Upgrade git to >= 2.13 (flag was added in 2.13).","Re-initialize submodules: `git submodule update --init --recursive`.","Run from the main repo root instead of inside a submodule if submodule info is not needed.","Repair or remove the broken worktree."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import {execSync} from 'child_process';\nfunction gitSupportsSuperproject(cwd: string): boolean {\n  try {\n    execSync('git rev-parse --show-superproject-working-tree', {cwd, stdio: 'ignore'});\n    return true;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const roots = await getGitAllRepoRoots(cwd);\n} catch (e) {\n  const cause = (e as Error).cause as Error;\n  if (/show-superproject-working-tree/.test(cause?.message ?? '')) {\n    // upgrade git or repair submodule/worktree state\n  }\n}","preventionTips":["Use git >= 2.13 in all environments.","Keep submodules fully initialized (`git submodule update --init`).","Avoid running submodule-aware builds from inside broken worktrees."],"tags":["git","vcs","submodule","version-compat"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}