chenhg5/cc-connect · error

codex app-server start: %w

Error message

codex app-server start: %w

What it means

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.

Source

Thrown at agent/codex/appserver_session.go:277

	}
	if len(env) > 0 {
		cmd.Env = core.MergeEnv(os.Environ(), env)
	}

	stdin, err := cmd.StdinPipe()
	if err != nil {
		return fmt.Errorf("codex app-server stdin pipe: %w", err)
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return fmt.Errorf("codex app-server stdout pipe: %w", err)
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		return fmt.Errorf("codex app-server stderr pipe: %w", err)
	}
	if err := cmd.Start(); err != nil {
		return fmt.Errorf("codex app-server start: %w", err)
	}

	s.procMu.Lock()
	s.cmd = cmd
	s.stdin = stdin
	s.procMu.Unlock()

	slog.Info("codex app-server session started", "transport", "stdio", "pid", cmd.Process.Pid, "work_dir", s.workDir)

	s.wg.Add(3)
	go s.readLoop(stdout)
	go s.stderrLoop(stderr)
	go s.waitLoop()
	return nil
}

func (s *appServerSession) initialize() error {
	params := map[string]any{

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify the binary: run `which codex` (or the configured path) manually and confirm it executes.
  2. Check the agent's configured binary path/command in config.toml for typos or stale absolute paths.
  3. Ensure the binary is executable (chmod +x) and the target architecture/OS matches.
  4. Check for fork/resource limits (ulimit -u, container pids-limit) if the binary exists and runs manually.
  5. Confirm the working directory and environment passed to the command are valid.

Example fix

// before
opts := core.AgentOptions{Command: "/usr/local/bin/codex-app-server"}
// after
// ensure the binary exists before constructing:
if _, err := os.Stat("/usr/local/bin/codex-app-server"); err != nil {
    slog.Error("codex binary missing; install codex CLI or fix config path")
}
opts := core.AgentOptions{Command: "codex", Args: []string{"app-server"}}
Defensive patterns

Strategy: validation

Validate before calling

bin := cfg.CodexBinary // e.g. "codex"
path, err := exec.LookPath(bin)
if err != nil {
    return fmt.Errorf("codex binary %q not found on PATH; install codex CLI", bin)
}
if info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {
    return fmt.Errorf("codex binary %s missing or not executable", path)
}

Try / catch

if err := session.Start(ctx); err != nil {
    var execErr *exec.Error
    if errors.As(err, &execErr) {
        return fmt.Errorf("cannot execute %q: install codex CLI or fix config path", execErr.Name)
    }
    return err
}

Prevention

When it happens

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

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

Related errors


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