jackwener/OpenCLI · error · CommandExecutionError
Failed to open ChatGPT chat:
Error message
Failed to open ChatGPT chat:
What it means
Generic wrapper in `chatgpt-app new`: any error thrown while activating the app or creating a chat (that is not already a CommandExecutionError) is rethrown as a CommandExecutionError prefixed 'Failed to open ChatGPT chat: ' plus the underlying message. It groups osascript/exec failures into one user-facing error.
Source
Thrown at clis/chatgpt-app/new.js:58
' end try',
' end tell',
'end tell'
].map(line => `-e '${line.replace(/'/g, "'\\''")}'`).join(' ');
execSync(`osascript ${appleScript}`);
execSync("osascript -e 'delay 0.8'");
if (!isTemporaryChatVisible()) {
throw new CommandExecutionError('Temporary chat did not become visible after selecting the menu item');
}
} else {
execSync("osascript -e 'tell application \"System Events\" to keystroke \"n\" using command down'");
}
return [{ Status: 'Success' }];
}
catch (err) {
if (err instanceof CommandExecutionError) {
throw err;
}
throw new CommandExecutionError("Failed to open ChatGPT chat: " + getErrorMessage(err));
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the underlying message after the prefix to identify the real cause (ENOENT, permission, script error)
- Install/launch the ChatGPT Desktop app and grant the calling app Automation permission for ChatGPT and System Events
- Run the command from an interactive GUI terminal session, not a headless daemon
Defensive patterns
Strategy: try-catch
Validate before calling
execSync('ls /Applications/ChatGPT.app', { stdio: 'ignore' }); // throws if app missing Try / catch
try {
execSync('opencli chatgpt-app new');
} catch (e) {
const msg = String(e.message);
if (msg.includes('ENOENT')) console.error('osascript or command not found - run on macOS');
else if (msg.includes('not allowed assistive')) console.error('Grant Accessibility/Automation permissions');
else console.error('Failed to open ChatGPT chat:', msg);
} Prevention
- Run from an interactive macOS GUI session, not a headless daemon
- Install the ChatGPT Desktop app and complete first-run permission prompts
- Log stderr (not just the wrapper prefix) to see root causes
When it happens
Trigger: `chatgpt-app new` where execSync('osascript ...') fails: osascript not found, ChatGPT app not installed/renamed, AppleScript Automation permission denied, System Events keystroke rejected, or spawn ENOENT/EACCES errors.
Common situations: First-run macOS permission prompts dismissed; ChatGPT Desktop app not installed; PATH lacking /usr/bin in exec environments; running under a daemon without GUI session access.
Related errors
- Failed to read from ChatGPT:
- Failed to send ChatGPT message:
- Temporary chat did not become visible after selecting the me
- Error querying ChatGPT application state
- ChatGPT Desktop integration requires macOS (osascript is not
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b7d82da7eb6b93cb.
Report an issue: GitHub.