{"record":{"id":"70a671d1978e0ebd","repo":"chenhg5/cc-connect","slug":"gemini-q-cli-not-found-in-path-install-with-np","errorCode":null,"errorMessage":"gemini: %q CLI not found in PATH, install with: npm i -g @google/gemini-cli","messagePattern":"gemini: %q CLI not found in PATH, install with: npm i -g @google/gemini-cli","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/gemini/gemini.go","lineNumber":75,"sourceCode":"\tswitch v := opts[\"timeout_mins\"].(type) {\n\tcase int64:\n\t\ttimeoutMins = v\n\tcase int:\n\t\ttimeoutMins = int64(v)\n\tcase float64:\n\t\ttimeoutMins = int64(v)\n\tdefault:\n\t\tif v != nil {\n\t\t\tslog.Debug(\"gemini: timeout_mins has unexpected type\", \"type\", fmt.Sprintf(\"%T\", v))\n\t\t}\n\t}\n\tvar timeout time.Duration\n\tif timeoutMins > 0 {\n\t\ttimeout = time.Duration(timeoutMins) * time.Minute\n\t}\n\n\tif _, err := exec.LookPath(cmd); err != nil {\n\t\treturn nil, fmt.Errorf(\"gemini: %q CLI not found in PATH, install with: npm i -g @google/gemini-cli\", cmd)\n\t}\n\n\treturn &Agent{\n\t\tworkDir:      workDir,\n\t\tmodel:        model,\n\t\tmode:         mode,\n\t\tcmd:          cmd,\n\t\tcliExtraArgs: extraArgs,\n\t\tconfigEnv:    core.ParseConfigEnv(opts),\n\t\ttimeout:      timeout,\n\t\tactiveIdx:    -1,\n\t}, nil\n}\n\nfunc normalizeMode(raw string) string {\n\tswitch strings.ToLower(strings.TrimSpace(raw)) {\n\tcase \"yolo\", \"auto\", \"force\", \"bypasspermissions\":\n\t\treturn \"yolo\"","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/gemini/gemini.go#L57-L93","documentation":"New() verifies the gemini CLI binary exists in PATH via exec.LookPath before constructing the Agent. If it is missing, construction fails immediately with an actionable install hint rather than failing later at session start. This is an early environment validation error.","triggerScenarios":"Calling New() (via CreateAgent from config) when the `gemini` binary is not installed or not on the PATH of the cc-connect process.","commonSituations":"Gemini CLI never installed; installed locally via npm without -g so it's not in PATH; cc-connect runs as a systemd service whose PATH lacks the user's npm global bin directory; PATH differs between shell and daemon.","solutions":["Install the CLI: `npm i -g @google/gemini-cli`","Verify with `which gemini` in the same environment cc-connect runs in","For daemons, set the full PATH (e.g. /usr/local/bin or npm global bin) in the systemd unit or config env","If the binary exists under a different name/path, symlink it into PATH"],"exampleFix":"// before: agent fails at startup with cryptic PATH issues in daemon\nexec.Command(\"gemini\", \"--version\")\n// after: pin absolute path / ensure PATH in service\n// /etc/systemd/system/cc-connect.service\n// Environment=PATH=/usr/local/bin:/home/user/.npm-global/bin","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"gemini\"); err != nil {\n  return fmt.Errorf(\"gemini CLI not installed or not in PATH; run: npm i -g @google/gemini-cli\")\n}","typeGuard":null,"tryCatchPattern":"agent, err := gemini.New(...)\nif err != nil && strings.Contains(err.Error(), \"CLI not found in PATH\") {\n  log.Fatal(\"install gemini CLI and ensure it is on the daemon's PATH\")\n}","preventionTips":["Install the CLI globally and verify with `which gemini` as the same user the daemon runs as","Set an explicit PATH in systemd/Docker environments","Add a startup doctor check (cc-connect doctor) that validates agent binaries"],"tags":["path","cli","dependency","environment"],"backgroundTag":"command-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}