{"record":{"id":"068f235aa13e15d7","repo":"mislav/hub","slug":"command-not-found","errorCode":null,"errorMessage":"command not found","messagePattern":"command not found","errorType":"exception","errorClass":"exec.Error","httpStatus":null,"severity":"critical","filePath":"cmd/cmd.go","lineNumber":125,"sourceCode":"\tverboseLog(cmd)\n\tc := exec.Command(cmd.Name, cmd.Args...)\n\tc.Stdin = cmd.Stdin\n\tc.Stdout = cmd.Stdout\n\tc.Stderr = cmd.Stderr\n\n\treturn c.Run()\n}\n\n// Exec runs command with exec(3)\n// Note that Windows doesn't support exec(3): http://golang.org/src/pkg/syscall/exec_windows.go#L339\nfunc (cmd *Cmd) Exec() error {\n\tverboseLog(cmd)\n\n\tbinary, err := exec.LookPath(cmd.Name)\n\tif err != nil {\n\t\treturn &exec.Error{\n\t\t\tName: cmd.Name,\n\t\t\tErr:  fmt.Errorf(\"command not found\"),\n\t\t}\n\t}\n\n\targs := []string{binary}\n\targs = append(args, cmd.Args...)\n\n\treturn syscall.Exec(binary, args, os.Environ())\n}\n\nfunc New(name string) *Cmd {\n\treturn &Cmd{\n\t\tName:   name,\n\t\tArgs:   []string{},\n\t\tStdin:  os.Stdin,\n\t\tStdout: os.Stdout,\n\t\tStderr: os.Stderr,\n\t}\n}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/cmd/cmd.go#L107-L143","documentation":"In hub's Exec, before running a git command it calls exec.LookPath(cmd.Name). If the binary cannot be found on PATH it wraps the failure in an exec.Error with a generic \"command not found\" message, naming the missing command. This is hub's way of reporting that an external program (usually git) required to run the command is not installed or not on PATH.","triggerScenarios":"Any hub command that shells out to git (nearly all of them) when git isn't installed or PATH is stripped (e.g. cron, CI container, minimal Docker image).","commonSituations":"git missing from the container image; PATH not inherited when hub is invoked from a cron job or systemd service; broken PATH after custom shell config; git uninstalled/upgraded mid-session.","solutions":["Install git (apt-get install git / brew install git) or verify `which git` succeeds.","Fix PATH in the execution environment so it includes /usr/bin (or wherever git lives).","If invoking hub from scripts/CI, export PATH explicitly before calling hub."],"exampleFix":"// before: minimal Dockerfile\nFROM scratch\nCOPY hub /usr/bin/hub\n// after\nFROM alpine\nRUN apk add --no-cache git\nCOPY hub /usr/bin/hub","handlingStrategy":"validation","validationCode":"if ! command -v git >/dev/null 2>&1; then\n  echo \"git is required by hub\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git in every environment hub runs in (Dockerfiles, CI images).","Export a sane PATH in cron/systemd/non-interactive contexts.","Smoke-test `hub --version && git --version` after environment changes."],"tags":["exec","path","dependency"],"backgroundTag":"command-not-found","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}