jackwener/OpenCLI · error · CommandExecutionError
Error querying ChatGPT application state
Error message
Error querying ChatGPT application state
What it means
`chatgpt-app status` runs an osascript query for ChatGPT's running state; if that execSync fails (osascript errors, app bundle missing, timeout) it throws this CommandExecutionError, discarding the underlying error detail.
Source
Thrown at clis/chatgpt-app/status.js:23
site: 'chatgpt-app',
name: 'status',
access: 'read',
description: 'Check if ChatGPT Desktop App is running natively on macOS',
domain: 'localhost',
strategy: Strategy.PUBLIC,
browser: false,
args: [],
columns: ['Status'],
func: async () => {
if (process.platform !== 'darwin') {
throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');
}
try {
const output = execSync("osascript -e 'application \"ChatGPT\" is running'", { encoding: 'utf-8' }).trim();
return [{ Status: output === 'true' ? 'Running' : 'Stopped' }];
}
catch {
throw new CommandExecutionError('Error querying ChatGPT application state');
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the ChatGPT Desktop app is installed at /Applications/ChatGPT.app
- Grant Automation permission (System Events / ChatGPT) to the calling terminal app
- Run the osascript command manually to see the raw error the wrapper hides
Example fix
// manual diagnosis
execSync("osascript -e 'application \"ChatGPT\" is running'"); // run directly to see stderr
// or catch and log
try { execSync('opencli chatgpt-app status'); } catch (e) { console.error(e.stderr?.toString()); } Defensive patterns
Strategy: try-catch
Validate before calling
const installed = fs.existsSync('/Applications/ChatGPT.app');
if (!installed) throw new Error('ChatGPT Desktop not installed'); Try / catch
try {
const st = execSync('opencli chatgpt-app status').toString().trim();
} catch (e) {
// wrapper hides the cause; run osascript directly to diagnose
try {
execSync("osascript -e 'application \"ChatGPT\" is running'", { stdio: 'inherit' });
} catch (raw) {
console.error('osascript stderr:', raw.stderr?.toString());
}
} Prevention
- Verify ChatGPT.app exists in /Applications before status checks
- Approve the Automation permission prompt for the calling app the first time
- Run status from a GUI user session, not launchd/root contexts without window server access
When it happens
Trigger: On macOS: osascript returns non-zero because the ChatGPT app is not installed (application not found), Automation permission denied, or the osascript process failed/timed out.
Common situations: ChatGPT Desktop uninstalled or renamed; first-time Automation permission prompt denied; running osascript from a context without a GUI session.
Related errors
- Temporary chat did not become visible after selecting the me
- Failed to open ChatGPT chat:
- Failed to read from ChatGPT:
- Failed to send ChatGPT message:
- ChatGPT Desktop integration requires macOS (osascript is not
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/023fdcb784fadc9a.
Report an issue: GitHub.