{"record":{"id":"09040886f51b0d10","repo":"google-gemini/gemini-cli","slug":"failed-to-start-shell-command-in-this-commandna","errorCode":null,"errorMessage":"Failed to start shell command in '${this.commandName}': ${executionResult.error.message}. Command: ${injection.resolvedCommand}","messagePattern":"Failed to start shell command in '(.+?)': (.+?)\\. Command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/services/prompt-processors/shellProcessor.ts","lineNumber":184,"sourceCode":"        const shellExecutionConfig = {\n          ...config.getShellExecutionConfig(),\n          defaultFg: activeTheme.colors.Foreground,\n          defaultBg: activeTheme.colors.Background,\n        };\n        const { result } = await ShellExecutionService.execute(\n          injection.resolvedCommand,\n          config.getTargetDir(),\n          () => {},\n          new AbortController().signal,\n          config.getEnableInteractiveShell(),\n          shellExecutionConfig,\n        );\n\n        const executionResult = await result;\n\n        // Handle Spawn Errors\n        if (executionResult.error && !executionResult.aborted) {\n          throw new Error(\n            `Failed to start shell command in '${this.commandName}': ${executionResult.error.message}. Command: ${injection.resolvedCommand}`,\n          );\n        }\n\n        // Append the output, making stderr explicit for the model.\n        processedPrompt += executionResult.output;\n\n        // Append a status message if the command did not succeed.\n        if (executionResult.aborted) {\n          processedPrompt += `\\n[Shell command '${injection.resolvedCommand}' aborted]`;\n        } else if (\n          executionResult.exitCode !== 0 &&\n          executionResult.exitCode !== null\n        ) {\n          processedPrompt += `\\n[Shell command '${injection.resolvedCommand}' exited with code ${executionResult.exitCode}]`;\n        } else if (executionResult.signal !== null) {\n          processedPrompt += `\\n[Shell command '${injection.resolvedCommand}' terminated by signal ${executionResult.signal}]`;\n        }","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/services/prompt-processors/shellProcessor.ts#L166-L202","documentation":"Thrown when ShellExecutionService.execute() returns a result whose .error is set and .aborted is false — i.e. the shell command failed to spawn/start (a spawn error, not a cancellation). The message includes the underlying error message and the resolved command.","triggerScenarios":"ShellExecutionService spawns the resolved command and the spawn fails (ENOENT for a missing binary, EACCES, invalid shell configuration); executionResult.error is populated and executionResult.aborted is false.","commonSituations":"The command references a binary not on PATH inside the target dir; the configured shell is invalid or missing; insufficient permissions to execute; the spawned program exited with a spawn-level error before producing output.","solutions":["Check the error.message in the thrown text — ENOENT usually means a missing binary, EACCES a permission problem.","Verify the command runs standalone in config.getTargetDir() with the same shell (getShellConfiguration()).","Ensure the binary is installed and on PATH (or use an absolute path) inside the sandbox/working directory.","Confirm the shell binary (bash/sh) is available in the execution environment."],"exampleFix":"# before — python not on PATH in sandbox\nreport !{python ./analyze.py} data\n# after\nreport !{/usr/bin/python3 ./analyze.py} data","handlingStrategy":"validation","validationCode":"import commandExists from 'command-exists';\nfunction firstToken(cmd: string): string | null {\n  const t = cmd.trim().split(/\\s+/)[0];\n  return t || null;\n}\nfunction commandIsSpawnable(cmd: string, cwd: string): boolean {\n  const bin = firstToken(cmd);\n  if (!bin) return false;\n  if (fs.existsSync(path.resolve(cwd, bin)) || fs.existsSync(bin)) return true;\n  try { return commandExists.sync(bin); } catch { return false; }\n}","typeGuard":"interface ExecResult { error?: Error; aborted?: boolean; output?: string; exitCode?: number | null; signal?: number | null; }\nfunction isSpawnError(r: ExecResult): boolean {\n  return !!r.error && !r.aborted;\n}","tryCatchPattern":"try {\n  await shellProcessor.process(prompt, ctx);\n} catch (e) {\n  if (e instanceof Error && /Failed to start shell command/.test(e.message)) {\n    // inspect embedded error.message: ENOENT=missing binary, EACCES=permissions\n  }\n  throw e;\n}","preventionTips":["Ensure referenced binaries are installed and on PATH inside the working directory/sandbox.","Prefer absolute paths to binaries when the sandbox PATH is minimal.","Verify the configured shell (getShellConfiguration()) exists in the execution environment."],"tags":["shell","spawn","execution","filesystem","prompt-processor"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}