From ec7f0345b0be284dee1845f46b11a99c7dd06076 Mon Sep 17 00:00:00 2001 From: sudacode Date: Mon, 17 Aug 2026 01:45:47 -0700 Subject: [PATCH] fix(notifications): spawn notify-send without AppImage library overrides Electron AppImages export LD_LIBRARY_PATH pointing at bundled libraries whose stale libnotify kills the system notify-send with a symbol lookup error, permanently disabling in-place replacement and forcing the flickering Electron close-and-reopen fallback. Drop the override from the child environment so the system binary resolves its own libraries. --- src/core/utils/notification.test.ts | 18 +++++++++++++++++- src/core/utils/notification.ts | 13 ++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/core/utils/notification.test.ts b/src/core/utils/notification.test.ts index ade25e91..bbecc1d6 100644 --- a/src/core/utils/notification.test.ts +++ b/src/core/utils/notification.test.ts @@ -1,6 +1,22 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { createNotifySendReplacer, resolveDefaultNotificationIconPath } from './notification'; +import { + buildNotifySendEnv, + createNotifySendReplacer, + resolveDefaultNotificationIconPath, +} from './notification'; + +test('notify-send child environment drops the AppImage library-path override', () => { + const env = buildNotifySendEnv({ + LD_LIBRARY_PATH: '/tmp/.mount_SubMinXXXXXX/usr/lib', + DBUS_SESSION_BUS_ADDRESS: 'unix:path=/run/user/1000/bus', + HOME: '/home/user', + }); + + assert.equal(env.LD_LIBRARY_PATH, undefined); + assert.equal(env.DBUS_SESSION_BUS_ADDRESS, 'unix:path=/run/user/1000/bus'); + assert.equal(env.HOME, '/home/user'); +}); test('default notification icon resolves packaged SubMiner asset when no per-notification icon is provided', () => { const path = resolveDefaultNotificationIconPath({ diff --git a/src/core/utils/notification.ts b/src/core/utils/notification.ts index 20688eb1..86d1f07c 100644 --- a/src/core/utils/notification.ts +++ b/src/core/utils/notification.ts @@ -203,8 +203,19 @@ export function createNotifySendReplacer( }; } +/** + * Electron AppImages export `LD_LIBRARY_PATH=/usr/lib`, whose bundled libnotify predates the + * symbols the system notify-send links against, so an inherited environment kills the child with a + * symbol lookup error before it can send anything. A system binary resolves its own libraries fine, + * so the override is dropped entirely rather than filtered. + */ +export function buildNotifySendEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv { + const { LD_LIBRARY_PATH: _dropped, ...rest } = env; + return rest; +} + const showLinuxReplaceableNotification = createNotifySendReplacer((args, callback) => - execFile('notify-send', args, { timeout: 5_000 }, (error, stdout) => + execFile('notify-send', args, { timeout: 5_000, env: buildNotifySendEnv() }, (error, stdout) => callback(error, stdout ?? ''), ), );