diff options
| author | Castor Gemini <[email protected]> | 2025-08-22 08:16:56 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-22 08:16:56 -0500 | 
| commit | 314cd07836cf4c9730534958ad277a8b597b41e5 (patch) | |
| tree | fd826d367ca86c79f8bec8331ad2350fe3d2b92e | |
| parent | 1e7a6d9e1e72b26c96f17115c39791f29872aabb (diff) | |
fix(ui): Use execFile with absolute path to run gemini --output
| -rw-r--r-- | packages/cli/src/ui/components/messages/GeminiMessage.tsx | 28 | 
1 files changed, 10 insertions, 18 deletions
diff --git a/packages/cli/src/ui/components/messages/GeminiMessage.tsx b/packages/cli/src/ui/components/messages/GeminiMessage.tsx index deed1eb0..0df9aaa3 100644 --- a/packages/cli/src/ui/components/messages/GeminiMessage.tsx +++ b/packages/cli/src/ui/components/messages/GeminiMessage.tsx @@ -4,9 +4,10 @@   * SPDX-License-Identifier: Apache-2.0   */ +import { appendFileSync } from 'fs';  import React, { useEffect } from 'react';  import { Text, Box } from 'ink'; -import { exec } from 'child_process'; +import { execFile } from 'child_process';  import { MarkdownDisplay } from '../../utils/MarkdownDisplay.js';  import { Colors } from '../../colors.js';  import { SCREEN_READER_MODEL_PREFIX } from '../../constants.js'; @@ -25,33 +26,23 @@ export const GeminiMessage: React.FC<GeminiMessageProps> = ({    terminalWidth,  }) => {    // --- Start of Modification --- -  // Use a useEffect hook to trigger a side effect when the component renders -  // with new text. This is the correct way to handle non-UI logic in React.    useEffect(() => {      // Don't execute for pending or empty responses.      if (isPending || !text) {        return;      } -    // The command to run. -    const commandToRun = 'gemini --output'; +    // Use the absolute path to the gemini binary to avoid PATH issues. +    const command = '/home/jcarr/go/bin/gemini'; +    const args = ['--output', text]; -    // IMPORTANT: Pass the AI's message via an environment variable -    // to prevent shell injection vulnerabilities. -    const options = { -      env: { -        ...process.env, -        GEMINI_MESSAGE: text, -      }, -    }; - -    exec(commandToRun, options, (error, stdout, stderr) => { +    execFile(command, args, (error, stdout, stderr) => {        if (error) { -        // Display errors in the debug console for visibility. -        console.error(`exec error: ${error.message}`); +        // For debugging, you can log errors to a file. +        // appendFileSync('/tmp/gemini-cli-debug.log', `execFile error: ${error.message}\n`); +        console.error(`execFile error: ${error.message}`);          return;        } -      // You could also display stdout or stderr if needed.      });    }, [text, isPending]); // This hook re-runs only when `text` or `isPending` changes.    // --- End of Modification --- @@ -80,3 +71,4 @@ export const GeminiMessage: React.FC<GeminiMessageProps> = ({      </Box>    );  }; +  | 
