chenhg5/cc-connect · error

copilot: %q CLI not found in PATH, please install it first

Error message

copilot: %q CLI not found in PATH, please install it first

What it means

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.

Source

Thrown at agent/copilot/copilot.go:53

	providers    []core.ProviderConfig
	activeIdx    int // -1 = no provider set
	sessionEnv   []string

	mu sync.RWMutex
}

func New(opts map[string]any) (core.Agent, error) {
	workDir, _ := opts["work_dir"].(string)
	if workDir == "" {
		workDir = "."
	}
	cmd, extraArgs := core.ParseCmdOpts(opts, "copilot")
	model, _ := opts["model"].(string)
	mode, _ := opts["mode"].(string)
	mode = normalizeMode(mode)

	if _, err := exec.LookPath(cmd); err != nil {
		return nil, fmt.Errorf("copilot: %q CLI not found in PATH, please install it first", cmd)
	}

	return &Agent{
		workDir:      workDir,
		cmd:          cmd,
		cliExtraArgs: extraArgs,
		configEnv:    core.ParseConfigEnv(opts),
		model:        model,
		mode:         mode,
		activeIdx:    -1,
	}, nil
}

func normalizeMode(raw string) string {
	switch strings.ToLower(strings.TrimSpace(raw)) {
	case "bypasspermissions", "bypass-permissions", "bypass_permissions", "yolo":
		return "bypassPermissions"
	default:

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Install the Copilot CLI: `npm install -g @github/copilot` (then verify `copilot --version`)
  2. Find the absolute path (`which copilot`) and set it as the `cmd` option in config.toml
  3. Fix PATH for the daemon context — systemd: Environment="PATH=/home/u/.local/bin:/usr/local/bin:..."
  4. Check user/permission mismatch: the binary may exist for your shell user but not for the service account

Example fix

// before: fails with unclear PATH under systemd
agent, err := copilot.New(opts)
// after: resolve absolute path explicitly in config
opts["cmd"] = "/home/user/.npm-global/bin/copilot" // output of `which copilot`
agent, err := copilot.New(opts)
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("copilot"); err != nil {
    return errors.New("copilot CLI not on PATH; install via `npm i -g @github/copilot` or set cmd option")
}

Try / catch

agent, err := copilot.New(opts)
if err != nil && strings.Contains(err.Error(), "CLI not found in PATH") {
    var le *exec.Error
    _ = errors.As(err, &le)
    return fmt.Errorf("install %s or set cmd to its absolute path: %w", le.Name, err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/3586d177c1a7d19e. Report an issue: GitHub.