{"record":{"id":"ce3fb6a90815d744","repo":"vercel/turborepo","slug":"git-args-0-failed-formaterror-error","errorCode":null,"errorMessage":"`git ${args[0]}` failed:\n${formatError(error)}","messagePattern":"`git (.+?)` failed:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/turbo-utils/src/examples.ts","lineNumber":517,"sourceCode":"function formatError(error: unknown): string {\n  if (error && typeof error === \"object\" && \"stderr\" in error) {\n    const { stderr } = error as { stderr?: unknown };\n    if (typeof stderr === \"string\" || Buffer.isBuffer(stderr)) {\n      const output = stderr.toString().trim();\n      if (output) {\n        return output;\n      }\n    }\n  }\n\n  return error instanceof Error ? error.message : String(error);\n}\n\nfunction runGit(args: Array<string>, cwd?: string): void {\n  try {\n    execFileSync(\"git\", args, { cwd, stdio: \"pipe\" });\n  } catch (error) {\n    throw new Error(`\\`git ${args[0]}\\` failed:\\n${formatError(error)}`);\n  }\n}\n\nfunction cleanupCloneDirectory(tempDir: string): void {\n  try {\n    rmSync(tempDir, {\n      recursive: true,\n      force: true,\n      maxRetries: 5,\n      retryDelay: 100\n    });\n  } catch (error) {\n    warn(\n      `Unable to remove temporary directory ${tempDir}:\\n${formatError(error)}`\n    );\n  }\n}\n","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/packages/turbo-utils/src/examples.ts#L499-L535","documentation":"Thrown by runGit in @turbo-utils/examples.ts when an execFileSync('git', ...) invocation exits non-zero; downloadAndExtractExample uses a partial clone (no blobs, no checkout) then sparse-checkout to extract one example. The message names the failing git subcommand and includes stderr captured from the process, so the underlying git error is visible.","triggerScenarios":"git not installed or not on PATH (ENOENT surfaces as spawn failure), no network access to github.com for git clone --filter=blob:none, corporate proxies blocking the git smart-http protocol, old git versions that do not support --filter/sparse-checkout, or disk/permission errors writing .turbo-clone-temp.","commonSituations":"Minimal Docker/CI images without git installed, locked-down corporate networks, git < 2.25 (sparse-checkout) or < 2.19 (partial clone), read-only destination directories, or authentication prompts on a private repo.","solutions":["Read the stderr embedded in the message; it is git's own error output and pinpoints the cause","Confirm git is installed and on PATH: git --version (partial clone needs git >= 2.19, sparse-checkout >= 2.25)","If a proxy is required, configure git: git config --global http.proxy http://proxy:port","Verify network access to github.com from the environment","Ensure the destination root is writable so .turbo-clone-temp can be created"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { execFileSync } from \"node:child_process\";\n\nfunction gitAvailable(): boolean {\n  try {\n    execFileSync(\"git\", [\"--version\"], { stdio: \"pipe\" });\n    return true;\n  } catch {\n    return false;\n  }\n}\n// if (!gitAvailable()) throw new Error(\"git >= 2.25 is required (sparse checkout)\");","typeGuard":null,"tryCatchPattern":"try {\n  await downloadAndExtractExample(root, name);\n} catch (err) {\n  const msg = String(err?.message);\n  if (msg.includes(\"ENOSYS\") || msg.includes(\"not found\")) {\n    throw new Error(\"git binary missing on PATH\", { cause: err });\n  }\n  throw err; // message already embeds git's stderr - surface it to the user\n}","preventionTips":["Install git >= 2.25 in CI images (partial clone + sparse-checkout)","Configure http.proxy in git config for corporate networks before running create-turbo","Ensure write permission on the destination root so .turbo-clone-temp can be created and cleaned"],"tags":["git","network","spawn","create-turbo","cli"],"backgroundTag":"git-clone-failed","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}