{"record":{"id":"f5ba0fac79389c29","repo":"chenhg5/cc-connect","slug":"kimisession-start-w","errorCode":null,"errorMessage":"kimiSession: start: %w","messagePattern":"kimiSession: start: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/kimi/session.go","lineNumber":220,"sourceCode":"\tcmd := exec.CommandContext(ctx, ks.cmd, args...)\n\tcmd.WaitDelay = 1 * time.Second\n\tcmd.Dir = ks.workDir\n\tenv := os.Environ()\n\tif len(ks.extraEnv) > 0 {\n\t\tenv = core.MergeEnv(env, ks.extraEnv)\n\t}\n\tcmd.Env = env\n\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kimiSession: stdout pipe: %w\", err)\n\t}\n\n\tvar stderrBuf bytes.Buffer\n\tcmd.Stderr = &stderrBuf\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"kimiSession: start: %w\", err)\n\t}\n\n\tstarted = true\n\tks.wg.Add(1)\n\tgo func() {\n\t\tdefer cancel()\n\t\tks.readLoop(ctx, cmd, stdout, &stderrBuf, append(imageRefs, fileRefs...))\n\t}()\n\n\treturn nil\n}\n\nfunc (ks *kimiSession) readLoop(ctx context.Context, cmd *exec.Cmd, stdout io.ReadCloser, stderrBuf *bytes.Buffer, tempFiles []string) {\n\tdefer ks.wg.Done()\n\tdefer func() {\n\t\tfor _, f := range tempFiles {\n\t\t\tos.Remove(f)\n\t\t}","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/kimi/session.go#L202-L238","documentation":"After building the exec.Cmd, kimiSession.Send calls cmd.Start(); any launch failure is wrapped as `kimiSession: start: %w`. The kimi process never starts, no events are emitted, and Send returns this error synchronously. Typical underlying errors are exec.ErrNotFound (binary missing), permission denied (non-executable binary), and chdir errors (missing workDir).","triggerScenarios":"Send() on a fresh kimiSession where: (1) the kimi binary is not in the daemon process's PATH (systemd/launchd have minimal PATHs), (2) the binary lacks the executable bit, (3) the configured working directory does not exist or is inaccessible, or (4) an invalid command path is configured.","commonSituations":"cc-connect running under systemd with PATH=/usr:/bin while kimi is installed via npm/homebrew into a user bin dir; installing kimi after the daemon started; pointing the agent's work_dir at a deleted/renamed project folder; containers without the CLI installed.","solutions":["Verify resolution in the daemon's environment: `sudo -u <daemon-user> which kimi`; if empty, install kimi or configure the absolute binary path in config.toml.","Fix the executable bit: `chmod +x $(which kimi)`.","Ensure the configured workDir exists and is accessible to the daemon user.","For systemd, add Environment=PATH=/usr/local/bin:/usr/bin:/bin (or an absolute command path) to the unit and restart."],"exampleFix":"// config.toml — before\n[agents.kimi]\ncommand = \"kimi\"  # not found under systemd's minimal PATH\n\n// after\n[agents.kimi]\ncommand = \"/home/user/.local/bin/kimi\"","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(kimiCmd); err != nil {\n    return fmt.Errorf(\"kimi CLI %q not installed or not in PATH for this process\", kimiCmd)\n}\nif info, err := os.Stat(workDir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"workDir %q does not exist\", workDir)\n}","typeGuard":null,"tryCatchPattern":"if err := sess.Send(prompt, msgID, nil, nil); err != nil {\n    if strings.Contains(err.Error(), \"kimiSession: start:\") {\n        return fmt.Errorf(\"cannot launch kimi CLI (check installation/PATH/workDir): %w\", err)\n    }\n    return err\n}","preventionTips":["Install the kimi CLI on every host/container image that runs cc-connect","Configure the absolute binary path in config.toml instead of relying on PATH","Check `sudo -u <daemon-user> which kimi` — daemon users often have minimal PATHs","Validate workDir existence in startup/doctor checks before accepting messages"],"tags":["go","process-start","cli"],"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"}