Skip to content

fix: handle missing notification settings app on Linux#8304

Open
mvanhorn wants to merge 3 commits intoaaif-goose:mainfrom
mvanhorn:fix/8292-linux-notification-enoent
Open

fix: handle missing notification settings app on Linux#8304
mvanhorn wants to merge 3 commits intoaaif-goose:mainfrom
mvanhorn:fix/8292-linux-notification-enoent

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Apr 4, 2026

Summary

Fixes a crash when clicking "Open Settings" in Settings > App > Notifications on Linux desktops that don't have GNOME, KDE, or XFCE installed.

Changes

In ui/desktop/src/main.ts, the open-notifications-settings IPC handler used spawn() inside try/catch blocks for each desktop environment. Node.js spawn() does not throw synchronously on ENOENT; it emits the error asynchronously via the ChildProcess 'error' event. The try/catch blocks never fired, so the app crashed with spawn gnome-control-center ENOENT.

Fix: added a canSpawn(cmd) helper that uses execFileSync('which', [cmd]) to check if the binary exists before calling spawn(). Each DE check now uses if (canSpawn(...)) instead of try { spawn(...) } catch. When no settings app is found, returns false instead of crashing.

Testing

Verified the logic by reading the Node.js child_process docs confirming spawn() ENOENT behavior. The fix is a straightforward control flow change with no new dependencies.

Fixes #8292

This contribution was developed with AI assistance (Codex).

Replace spawn() try/catch with canSpawn() check using
execFileSync('which', [cmd]). Node.js spawn() emits ENOENT
asynchronously via the error event, so try/catch never catches
it. canSpawn() detects missing binaries before spawning.
Douwe Osinga added 2 commits April 8, 2026 14:05
The first canSpawn('gnome-control-center') check already covers this case.
If it wasn't found then, it won't be found again without args.

Signed-off-by: Douwe Osinga <douwe@squareup.com>
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix — spawn() indeed doesn't throw synchronously on ENOENT, so the existing try/catch was dead code. The canSpawn approach using which is clean and correct.

I pushed a small cleanup commit removing the redundant fallback canSpawn('gnome-control-center') check — if it wasn't found the first time, checking again without args won't help.

One thing to fix: your original commit is missing the DCO sign-off. Please amend it with git commit --amend -s and force-push so the DCO check passes.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a5d31de56

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Linux: Try different desktop environments
function canSpawn(cmd: string): boolean {
try {
execFileSync('which', [cmd], { stdio: 'ignore' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove hard dependency on which for command detection

The new Linux path now relies on execFileSync('which', [cmd]) to decide whether a settings binary exists, but which is not guaranteed to be installed on all Linux desktops. In environments where gnome-control-center/systemsettings5 exists but which is missing, canSpawn returns false for every check and this handler will incorrectly fail instead of opening settings, which is a behavior regression introduced by this change.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop crash on Linux: Notifications "Open Settings" tries to spawn gnome-control-center (ENOENT)

2 participants