{"record":{"id":"7cfd8b4c1c45f0e8","repo":"chenhg5/cc-connect","slug":"opencode-q-cli-not-found-in-path-install-from","errorCode":null,"errorMessage":"opencode: %q CLI not found in PATH, install from: https://github.com/opencode-ai/opencode","messagePattern":"opencode: %q CLI not found in PATH, install from: https://github\\.com/opencode-ai/opencode","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/opencode/opencode.go","lineNumber":83,"sourceCode":"\tworkDir, _ := opts[\"work_dir\"].(string)\n\tif workDir == \"\" {\n\t\tworkDir = \".\"\n\t}\n\tmodel, _ := opts[\"model\"].(string)\n\tmode, _ := opts[\"mode\"].(string)\n\tmode = normalizeMode(mode)\n\tcmd, extraArgs := core.ParseCmdOpts(opts, \"opencode\")\n\tagentName, _ := opts[\"agent\"].(string) // --agent flag for plugin-defined agents (#1210)\n\tccDataDir, _ := opts[\"cc_data_dir\"].(string)\n\tccProject, _ := opts[\"cc_project\"].(string)\n\tmodelCachePath := opencodeProjectModelCachePath(ccDataDir, ccProject)\n\tpersistentModelCache, err := loadOpencodePersistentModelCache(modelCachePath)\n\tif err != nil {\n\t\tslog.Warn(\"opencode: load persistent model cache failed\", \"path\", modelCachePath, \"err\", err)\n\t}\n\n\tif _, err := exec.LookPath(cmd); err != nil {\n\t\treturn nil, fmt.Errorf(\"opencode: %q CLI not found in PATH, install from: https://github.com/opencode-ai/opencode\", 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\tagentName:            agentName,\n\t\tactiveIdx:            -1,\n\t\tmodelCachePath:       modelCachePath,\n\t\tpersistentModelCache: persistentModelCache,\n\t}, nil\n}\n\nfunc opencodeProjectModelCachePath(dataDir, project string) string {\n\tif dataDir == \"\" || project == \"\" {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/opencode/opencode.go#L65-L101","documentation":"opencode.New validates that the configured opencode CLI binary exists via exec.LookPath before returning the Agent; if not found in PATH, construction fails with this message pointing at the project's install URL. It is a startup-time configuration error: the factory refuses to build an agent that could never launch a session.","triggerScenarios":"Calling New() (directly or via core.CreateAgent from config.toml) when the `opencode` binary is absent from the current process's PATH, or the configured command name/alias does not exist.","commonSituations":"opencode not installed at all; installed via npm/go-install into a bin dir not on the daemon's PATH under systemd; typo in the agent command config; container images that omit the CLI.","solutions":["Install opencode (https://github.com/opencode-ai/opencode) e.g. `go install github.com/opencode-ai/opencode@latest` or grab a release binary.","Verify in the daemon's environment: `sudo -u <user> which opencode`; fix PATH in the service unit or set the absolute path in config.toml.","If the command is customized, set the agent's command config option to the full binary path.","Ensure the binary is executable: `chmod +x $(which opencode)`."],"exampleFix":"// config.toml — before\n[agents.opencode]\ncommand = \"opencode\"  # not on the daemon's PATH\n\n// after\n[agents.opencode]\ncommand = \"/home/user/go/bin/opencode\"","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"opencode\"); err != nil {\n    // install or point config.toml at the absolute binary path before constructing the agent\n    return fmt.Errorf(\"opencode CLI must be installed: https://github.com/opencode-ai/opencode\")\n}","typeGuard":null,"tryCatchPattern":"agent, err := opencode.New(workDir, model, mode, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"CLI not found in PATH\") {\n        return fmt.Errorf(\"please install opencode (see project README) or set the command path in config.toml\")\n    }\n    return err\n}","preventionTips":["Run cc-connect's doctor/startup check that verifies agent CLIs before going live","Use absolute command paths in config.toml to be immune to daemon PATH differences","Install opencode in the same image/unit that runs cc-connect","After CLI upgrades, restart the daemon so LookPath caches resolve correctly"],"tags":["go","cli","path","configuration"],"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"}