{"record":{"id":"3586d177c1a7d19e","repo":"chenhg5/cc-connect","slug":"copilot-q-cli-not-found-in-path-please-install","errorCode":null,"errorMessage":"copilot: %q CLI not found in PATH, please install it first","messagePattern":"copilot: %q CLI not found in PATH, please install it first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/copilot/copilot.go","lineNumber":53,"sourceCode":"\tproviders    []core.ProviderConfig\n\tactiveIdx    int // -1 = no provider set\n\tsessionEnv   []string\n\n\tmu sync.RWMutex\n}\n\nfunc New(opts map[string]any) (core.Agent, error) {\n\tworkDir, _ := opts[\"work_dir\"].(string)\n\tif workDir == \"\" {\n\t\tworkDir = \".\"\n\t}\n\tcmd, extraArgs := core.ParseCmdOpts(opts, \"copilot\")\n\tmodel, _ := opts[\"model\"].(string)\n\tmode, _ := opts[\"mode\"].(string)\n\tmode = normalizeMode(mode)\n\n\tif _, err := exec.LookPath(cmd); err != nil {\n\t\treturn nil, fmt.Errorf(\"copilot: %q CLI not found in PATH, please install it first\", cmd)\n\t}\n\n\treturn &Agent{\n\t\tworkDir:      workDir,\n\t\tcmd:          cmd,\n\t\tcliExtraArgs: extraArgs,\n\t\tconfigEnv:    core.ParseConfigEnv(opts),\n\t\tmodel:        model,\n\t\tmode:         mode,\n\t\tactiveIdx:    -1,\n\t}, nil\n}\n\nfunc normalizeMode(raw string) string {\n\tswitch strings.ToLower(strings.TrimSpace(raw)) {\n\tcase \"bypasspermissions\", \"bypass-permissions\", \"bypass_permissions\", \"yolo\":\n\t\treturn \"bypassPermissions\"\n\tdefault:","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/copilot/copilot.go#L35-L71","documentation":"The copilot agent constructor validates that the configured CLI binary (default `copilot`, or the cmd option) exists on PATH before creating the Agent. This error names the missing binary and instructs the user to install it. It is thrown at construction time so misconfiguration fails immediately instead of at first message send.","triggerScenarios":"New(opts) calls exec.LookPath(cmd) and gets exec.ErrNotFound: the `copilot` CLI (or the custom `cmd` option value) is not installed, not on the PATH of the cc-connect process, or the cmd option is misspelled. Exercised by TestNew_MissingBinary.","commonSituations":"GitHub Copilot CLI not installed (`npm i -g @github/copilot`); cc-connect launched by systemd/launchd with a PATH that omits nvm/homebrew bin directories; typo in the cmd config option; binary installed only for a different user.","solutions":["Install the Copilot CLI: `npm install -g @github/copilot` (then verify `copilot --version`)","Find the absolute path (`which copilot`) and set it as the `cmd` option in config.toml","Fix PATH for the daemon context — systemd: Environment=\"PATH=/home/u/.local/bin:/usr/local/bin:...\"","Check user/permission mismatch: the binary may exist for your shell user but not for the service account"],"exampleFix":"// before: fails with unclear PATH under systemd\nagent, err := copilot.New(opts)\n// after: resolve absolute path explicitly in config\nopts[\"cmd\"] = \"/home/user/.npm-global/bin/copilot\" // output of `which copilot`\nagent, err := copilot.New(opts)","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"copilot\"); err != nil {\n    return errors.New(\"copilot CLI not on PATH; install via `npm i -g @github/copilot` or set cmd option\")\n}","typeGuard":null,"tryCatchPattern":"agent, err := copilot.New(opts)\nif err != nil && strings.Contains(err.Error(), \"CLI not found in PATH\") {\n    var le *exec.Error\n    _ = errors.As(err, &le)\n    return fmt.Errorf(\"install %s or set cmd to its absolute path: %w\", le.Name, err)\n}","preventionTips":["Resolve `which copilot` and pin the absolute path in config.toml","Fix PATH in systemd/launchd units (nvm/homebrew dirs are often missing)","Verify the binary exists as the same user the service runs as","Add a doctor/startup check calling exec.LookPath for every configured agent"],"tags":["go","cli","copilot","path"],"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-14T00:17:10.932Z"}