facebook/docusaurus · error
Git not installed or not added to PATH!
Error message
Git not installed or not added to PATH!
What it means
Thrown early in deploy when `git --version` does not return exit code 0 (the hasGit() probe). Docusaurus deploy shells out to git repeatedly, so a missing git binary aborts immediately rather than failing later with a confusing error.
Source
Thrown at packages/docusaurus/src/commands/deploy.ts:97
): Promise<void> {
const siteDir = await fs.realpath(siteDirParam);
const {outDir, siteConfig, siteConfigPath} = await loadContext({
siteDir,
config: cliOptions.config,
outDir: cliOptions.outDir,
});
if (typeof siteConfig.trailingSlash === 'undefined') {
logger.warn(`When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
Otherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.
This behavior can have SEO impacts and create relative link issues.
`);
}
logger.info('Deploy command invoked...');
if (!hasGit()) {
throw new Error('Git not installed or not added to PATH!');
}
// Source repo is the repo from where the command is invoked
const {stdout} = exec('git remote get-url origin', {
log: false,
failfast: true,
});
const sourceRepoUrl = stdout.trim();
// The source branch; defaults to the currently checked out branch
const sourceBranch =
process.env.CURRENT_BRANCH ??
exec('git rev-parse --abbrev-ref HEAD', {
log: false,
failfast: true,
})
?.stdout?.toString()
.trim();View on GitHub (pinned to 3f483e80e3)
Solutions
- Install git (e.g. `apk add git` on alpine, `apt-get install git` on debian).
- Ensure git is on PATH: `which git && git --version` must succeed in the deploy shell.
- On Windows, restart the terminal after installing git so PATH updates take effect.
Example fix
# before (alpine image) docusaurus deploy # throws 'Git not installed' # after apk add --no-cache git docusaurus deploy
Defensive patterns
Strategy: validation
Validate before calling
import {execSync} from 'child_process';
function gitAvailable(): boolean {
try { execSync('git --version', {stdio: 'ignore'}); return true; }
catch { return false; }
}
if (!gitAvailable()) throw new Error('Install git before deploying.'); Prevention
- Install git in your CI/Docker image (`apk add git`, `apt-get install git`).
- Verify `git --version` in the same shell that runs deploy.
- On Windows, restart terminals after installing git.
When it happens
Trigger: Running `docusaurus deploy` in an environment without git installed or where git is not on PATH.
Common situations: Minimal Docker images (e.g. node:alpine without git), CI runners missing git, Windows machines where git is installed but not on PATH for the current shell.
Related errors
- Please set the GIT_USER environment variable, or explicitly
- Command returned unexpected exitCode ${result.exitCode}
- Error while executing command code=${obfuscateGitPass(cmd)}
- Missing project organization name. Did you forget to define
- Missing project name. Did you forget to define "projectName"
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/9f9c6f86ecdd37d1.
Report an issue: GitHub.