{"record":{"id":"7de536ff875c3ba9","repo":"chenhg5/cc-connect","slug":"codex-app-server-start-w","errorCode":null,"errorMessage":"codex app-server start: %w","messagePattern":"codex app-server start: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/appserver_session.go","lineNumber":277,"sourceCode":"\t}\n\tif len(env) > 0 {\n\t\tcmd.Env = core.MergeEnv(os.Environ(), env)\n\t}\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"codex app-server stdin pipe: %w\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"codex app-server stdout pipe: %w\", err)\n\t}\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"codex app-server stderr pipe: %w\", err)\n\t}\n\tif err := cmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"codex app-server start: %w\", err)\n\t}\n\n\ts.procMu.Lock()\n\ts.cmd = cmd\n\ts.stdin = stdin\n\ts.procMu.Unlock()\n\n\tslog.Info(\"codex app-server session started\", \"transport\", \"stdio\", \"pid\", cmd.Process.Pid, \"work_dir\", s.workDir)\n\n\ts.wg.Add(3)\n\tgo s.readLoop(stdout)\n\tgo s.stderrLoop(stderr)\n\tgo s.waitLoop()\n\treturn nil\n}\n\nfunc (s *appServerSession) initialize() error {\n\tparams := map[string]any{","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/appserver_session.go#L259-L295","documentation":"This error wraps a failure from cmd.Start() when launching the codex app-server binary. Start failed before any protocol exchange happened — either the binary could not be executed or process creation failed. The wrapped OS error (exec.Error, exec.ErrNotFound, permission errors) is the real cause.","triggerScenarios":"Calling StartSession on the codex agent with a binary path that does not exist, is not executable, or whose working directory/env setup fails; also failures from fork/exec resource limits (EAGAIN when hitting process/thread limits).","commonSituations":"Codex CLI not installed or not on PATH after a machine rebuild; config points to the wrong binary path; binary lacks +x after a permission-preserving copy; Docker image missing the CLI; fork limits hit under heavy load.","solutions":["Verify the binary: run `which codex` (or the configured path) manually and confirm it executes.","Check the agent's configured binary path/command in config.toml for typos or stale absolute paths.","Ensure the binary is executable (chmod +x) and the target architecture/OS matches.","Check for fork/resource limits (ulimit -u, container pids-limit) if the binary exists and runs manually.","Confirm the working directory and environment passed to the command are valid."],"exampleFix":"// before\nopts := core.AgentOptions{Command: \"/usr/local/bin/codex-app-server\"}\n// after\n// ensure the binary exists before constructing:\nif _, err := os.Stat(\"/usr/local/bin/codex-app-server\"); err != nil {\n    slog.Error(\"codex binary missing; install codex CLI or fix config path\")\n}\nopts := core.AgentOptions{Command: \"codex\", Args: []string{\"app-server\"}}","handlingStrategy":"validation","validationCode":"bin := cfg.CodexBinary // e.g. \"codex\"\npath, err := exec.LookPath(bin)\nif err != nil {\n    return fmt.Errorf(\"codex binary %q not found on PATH; install codex CLI\", bin)\n}\nif info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {\n    return fmt.Errorf(\"codex binary %s missing or not executable\", path)\n}","typeGuard":null,"tryCatchPattern":"if err := session.Start(ctx); err != nil {\n    var execErr *exec.Error\n    if errors.As(err, &execErr) {\n        return fmt.Errorf(\"cannot execute %q: install codex CLI or fix config path\", execErr.Name)\n    }\n    return err\n}","preventionTips":["Validate the configured binary path at config load / startup (doctor check).","Pin the codex CLI in deployment images and verify with `codex --version`.","Ensure chmod +x survives artifact packaging.","Check container images include the CLI and match host architecture."],"tags":["go","exec","process-start","binary-not-found"],"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"}