moeru-ai/airi · error · Error
requestMacOSScreenCapturePermission is only available on…
Error message
requestMacOSScreenCapturePermission is only available on macOS (darwin)
What it means
requestMacOSScreenCapturePermission() in packages/electron-screen-capture/src/main/utils.ts opens the macOS System Settings pane for Screen Recording via shell.openExternal, and is guarded to macOS only. On any other platform it throws before touching shell, because the x-apple.systempreferences URL scheme and the Screen Capture privacy pane do not exist there. It is exposed to renderers through the screenCapture.requestMacOSPermission eventa handler.
Solutions
- Only show/call the request-permission action when the app runs on macOS (gate in the renderer UI and/or in main before defining the flow).
- Pair it with checkMacOSScreenCapturePermission: only offer 'open settings' when the check returns 'denied' or 'not-determined' on darwin.
- On other platforms, skip the pre-flight entirely and let getSources/getDisplayMedia surface native failures instead.
Example fix
// before
await invoke(screenCapture.requestMacOSPermission) // throws on Windows/Linux
// after
if (await rendererPlatform() === 'darwin') {
await invoke(screenCapture.requestMacOSPermission)
} Defensive patterns
Strategy: validation
Validate before calling
const isDarwin = process.platform === 'darwin'
if (isDarwin && (await invoke(screenCapture.checkMacOSPermission)) !== 'granted') {
await invoke(screenCapture.requestMacOSPermission)
} Prevention
- Only render the 'Open privacy settings' button on macOS.
- Pair request with check: never call request when the platform cannot honor it or the check already returned granted.
- Centralize platform capability detection in one module consumed by both UI and IPC layers.
When it happens
Trigger: Invoking screenCapture.requestMacOSPermission (or the util directly) on Windows/Linux; wiring a 'Grant permission' button to this call without checking the host platform; running component/E2E tests on non-darwin machines that click through the permission UI.
Common situations: A permission-prompt UI built against macOS that ships to all platforms; automated tests on Linux CI reaching the request-permission branch; a shared 'first-run onboarding' flow that calls both check and request unconditionally.
Related errors
- checkMacOSScreenCapturePermission is only available on…
- No screen source available
- initScreenCaptureForMain should only be called once
- initScreenCaptureForWindow should only be called once per…
- Security-scoped Extension import access is not configured.
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/01d8332785a7af41.
Report an issue: GitHub.
Appendix: source
Thrown at packages/electron-screen-capture/src/main/utils.ts:41
id: source.id,
name: source.name,
display_id: source.display_id,
appIcon: source.appIcon != null && !source.appIcon.isEmpty() ? new Uint8Array(source.appIcon.toPNG().buffer) : undefined,
thumbnail: source.thumbnail != null ? new Uint8Array(source.thumbnail.toJPEG(90).buffer) : undefined,
}
}
export function checkMacOSScreenCapturePermission(): ReturnType<typeof systemPreferences.getMediaAccessStatus> {
if (!isMacOS) {
throw new Error('checkMacOSScreenCapturePermission is only available on macOS (darwin)')
}
return systemPreferences.getMediaAccessStatus('screen')
}
export function requestMacOSScreenCapturePermission(): void {
if (!isMacOS) {
throw new Error('requestMacOSScreenCapturePermission is only available on macOS (darwin)')
}
shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture')
}
View on GitHub (pinned to 677329427f)