{"record":{"id":"3fdfbdf4f46d699d","repo":"JanDeDobbeleer/oh-my-posh","slug":"s-environment-variable-not-set-do-you-have-the-p","errorCode":null,"errorMessage":"%s environment variable not set, do you have the posh-git module installed?","messagePattern":"(.+?) environment variable not set, do you have the posh-git module installed\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/posh_git.go","lineNumber":51,"sourceCode":"\tDeleted  []string `json:\"Deleted\"`\n\tUnmerged []string `json:\"Unmerged\"`\n}\n\nfunc (s *GitStatus) parsePoshGitStatus(p *poshGitStatus) {\n\tif p == nil {\n\t\treturn\n\t}\n\n\ts.Added = len(p.Added)\n\ts.Deleted = len(p.Deleted)\n\ts.Modified = len(p.Modified)\n\ts.Unmerged = len(p.Unmerged)\n}\n\nfunc (g *Git) hasPoshGitStatus() bool {\n\tenvStatus := g.env.Getenv(poshGitEnv)\n\tif envStatus == \"\" {\n\t\tlog.Error(fmt.Errorf(\"%s environment variable not set, do you have the posh-git module installed?\", poshGitEnv))\n\t\treturn false\n\t}\n\n\tvar posh poshGit\n\terr := json.Unmarshal([]byte(envStatus), &posh)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn false\n\t}\n\n\tg.setDir(posh.GitDir)\n\tg.Working = &GitStatus{}\n\tg.Working.parsePoshGitStatus(posh.Working)\n\tg.Staging = &GitStatus{}\n\tg.Staging.parsePoshGitStatus(posh.Index)\n\tg.HEAD = g.parsePoshGitHEAD(posh.Branch)\n\tg.stashCount = posh.StashCount\n\tg.Ahead = posh.AheadBy","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/posh_git.go#L33-L69","documentation":"On PowerShell, the git segment can read git status from the POSH_GIT_STATUS environment variable populated by the posh-git module. If the variable is unset, the segment logs '<env> environment variable not set, do you have the posh-git module installed?' and reports no posh-git status.","triggerScenarios":"Rendering the git segment with the poshgit display_mode in a shell where the posh-git module is not installed, not imported in the profile, or an older posh-git version that doesn't export POSH_GIT_STATUS.","commonSituations":"Using oh-my-posh in bash/zsh/fish where posh-git (a PowerShell-only module) never sets the variable; posh-git removed from the PowerShell $PROFILE; running oh-my-posh without importing posh-git before the prompt renders; typos in profile ordering so the prompt initializes before posh-git.","solutions":["Install and import the posh-git module in your PowerShell profile before oh-my-posh initializes (`Install-Module posh-git; Import-Module posh-git)`","Only enable the poshgit mode inside PowerShell; switch to the default git status mode in other shells","Verify `$env:POSH_GIT_STATUS` is populated after a prompt renders in PowerShell","Remove the poshgit option from the git segment config if you don't use posh-git"],"exampleFix":"// before: theme segment works only with posh-git\n\"git\": { \"display_mode\": \"poshgit\" }\n// after: default native status, no module needed\n\"git\": { \"display_mode\": \"files\" }","handlingStrategy":"validation","validationCode":"// check the variable is present before enabling poshgit mode\nif os.Getenv(\"POSH_GIT_STATUS\") == \"\" {\n    // module not imported; use default git status mode\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import-Module posh-git in your PowerShell $PROFILE before prompt init","Use poshgit display_mode only in PowerShell configs","Confirm $env:POSH_GIT_STATUS after rendering a prompt","Install posh-git via Install-Module and keep it updated"],"tags":["go","environment-variable","powershell","git","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}