ruvnet/ruflo · error · Error

Codex CLI path not found

Error message

Codex CLI path not found

What it means

getCodexCliInvocation() takes the stdout of a PATH lookup for the codex executable (e.g. `where codex` on Windows, `which -a codex` elsewhere), splits it into lines, and discards empties. Zero remaining lines means no codex binary was found, so MCP-config generation cannot build the launcher command and throws 'Codex CLI path not found'.

Source

Thrown at v3/@claude-flow/codex/src/mcp-config.ts:33

    command?: unknown;
    args?: unknown;
  } | null;
  startup_timeout_sec?: unknown;
}

export interface CodexCliInvocation {
  command: string;
  prefixArgs: string[];
}

export function getCodexCliInvocation(
  lookupOutput: string,
  platform: NodeJS.Platform = process.platform,
  commandShell = process.env.ComSpec || 'cmd.exe',
): CodexCliInvocation {
  const matches = lookupOutput.split(/\r?\n/).map(value => value.trim()).filter(Boolean);
  if (matches.length === 0) {
    throw new Error('Codex CLI path not found');
  }

  if (platform !== 'win32') {
    return { command: matches[0]!, prefixArgs: [] };
  }

  const executable = matches.find(match => /\.exe$/i.test(match));
  if (executable) {
    return { command: executable, prefixArgs: [] };
  }

  // npm installs expose extensionless and .cmd shims, neither of which can
  // be launched reliably with execFileSync on Windows. Resolve the shim via
  // cmd.exe without interpolating any user-controlled arguments.
  return { command: commandShell, prefixArgs: ['/d', '/s', '/c', 'codex'] };
}

export function getRufloMcpServerConfig(

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Install globally: `npm install -g @openai/codex`, then verify with `codex --version`
  2. Ensure the npm global bin directory (`npm bin -g` / `npm prefix -g` + bin) is on PATH, including for GUI/CI shells
  3. If you only have a local install, run the lookup from a shell where node_modules/.bin is on PATH, or npx from the project root

Example fix

# before: lookup returns nothing
$ where codex
INFO: Could not find files for the given pattern(s).
# after
npm install -g @openai/codex
codex --version  # verify
where codex      # now returns a path
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';
function codexOnPath(platform: NodeJS.Platform): boolean {
  const cmd = platform === 'win32' ? 'where codex' : 'command -v codex';
  try { return execSync(cmd, { encoding: 'utf8', stdio: ['ignore','pipe','pipe'] }).trim().length > 0; }
  catch { return false; }
}

Try / catch

try { inv = getCodexCliInvocation(lookup); } catch (e) { if (/Codex CLI path not found/.test(String(e))) { await installCodexCli(); lookup = relookup(); inv = getCodexCliInvocation(lookup); } else throw e; }

Prevention

When it happens

Trigger: The Codex CLI is not installed; it is installed local to a project (node_modules/.bin) but the lookup ran in a shell whose PATH lacks it; npx cache miss; on Windows only a non-.exe shim exists but even that is absent from PATH.

Common situations: Fresh machines without `npm i -g @openai/codex`; CI runners with minimal PATH; GUI-launched apps inheriting a stripped PATH where npm's global bin dir is missing; local installs mistaken for global.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/ac1ae35d272c9b9e. Report an issue: GitHub.