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
- Install globally: `npm install -g @openai/codex`, then verify with `codex --version`
- Ensure the npm global bin directory (`npm bin -g` / `npm prefix -g` + bin) is on PATH, including for GUI/CI shells
- 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
- Verify `codex --version` in the same shell/env the tool runs in (CI and GUI apps inherit different PATHs)
- Install the CLI globally and add npm's global bin dir to PATH
- Re-check PATH after node/npm version-manager switches
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
- String length ${len} exceeds remaining buffer
- Unknown GGUF array element type: ${elemType}
- Unknown GGUF value type: ${valueType}
- Invalid GGUF magic: 0x${magic.toString(16)} (expected 0x4655
- Unsupported GGUF version: ${version} (expected 2 or 3)
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/ac1ae35d272c9b9e.
Report an issue: GitHub.