Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

fix: keep the AppImage mount out of a relaunch's library path

Francesco Tenace08a3027700cc
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index 01a1967b..ea48db2b 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -7,7 +7,7 @@ import { closeAction, keepMainWindow } from './mainWindow'
import { titleBarOverlay, windowChrome } from './windowChrome'
import { x11Relaunch } from './display'
import { isAppRoute } from '../shared/routes'
-import { relaunchOptions } from './relaunch'
+import { relaunchOptions, stripAppImageEnv } from './relaunch'
import { capabilities, micListHelper, platformOf, supportedKinds } from '../shared/platform'
import { app, BrowserWindow, dialog, ipcMain, nativeTheme, Notification, protocol, shell } from 'electron'
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
@@ -90,7 +90,7 @@ process.on('uncaughtException', (err) => console.error('uncaught exception', err
// Linux on Wayland: once more through XWayland, so the widget and the card can float (display.ts)
const x11 = x11Relaunch(process.platform, process.argv, process.env, process.execPath)
-if (x11) { app.relaunch(x11); app.exit(0) }
+if (x11) { stripAppImageEnv(); app.relaunch(x11); app.exit(0) }
// One Yogurt at a time: a second launch focuses the existing window
else if (!app.requestSingleInstanceLock()) app.quit()
let win: BrowserWindow | undefined
@@ -456,6 +456,7 @@ app.whenReady().then(() => {
relaunch: () => {
if (activeMeeting()) return false
if (isFake()) { relaunched++; return true }
+ stripAppImageEnv()
app.relaunch(relaunchOptions(process.platform, app.isPackaged, process.execPath, process.env.APPIMAGE)); app.quit()
return true
},
diff --git a/app/src/main/relaunch.ts b/app/src/main/relaunch.ts
index 1e8e8e62..2c9a7a5e 100644
--- a/app/src/main/relaunch.ts
+++ b/app/src/main/relaunch.ts
@@ -1,5 +1,18 @@
import { dirname } from 'node:path'
+/**
+ * AppRun points LD_LIBRARY_PATH into the AppImage's mount, and that mount goes away with this process. The next
+ * AppImage runtime dlopens libnotify for its FUSE helper's error notice before AppRun runs again, and a library
+ * mapped from a mount that is going away kills the loader with SIGBUS. Only an AppImage sets APPDIR.
+ */
+export function stripAppImageEnv(env: NodeJS.ProcessEnv = process.env) {
+ const dir = env.APPDIR
+ if (!dir || !env.LD_LIBRARY_PATH) return
+ const kept = env.LD_LIBRARY_PATH.split(':').filter((entry) => entry && entry !== dir && !entry.startsWith(`${dir}/`))
+ if (kept.length) env.LD_LIBRARY_PATH = kept.join(':')
+ else delete env.LD_LIBRARY_PATH
+}
+
/** Launch Services retains the installed app's identity and Info.plist environment after a permission restart. */
export function relaunchOptions(platform: NodeJS.Platform, packaged: boolean, executable: string, appImage?: string) {
// Linux: the AppImage's mount goes away when Yogurt quits, so the AppImage itself starts again
diff --git a/app/test/relaunch.test.ts b/app/test/relaunch.test.ts
index 0a486139..d4ca9f7f 100644
--- a/app/test/relaunch.test.ts
+++ b/app/test/relaunch.test.ts
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
-import { relaunchOptions } from '../src/main/relaunch'
+import { relaunchOptions, stripAppImageEnv } from '../src/main/relaunch'
it('reopens the exact installed Mac bundle through Launch Services without inherited Electron arguments', () => {
expect(relaunchOptions('darwin', true, '/Users/sam/My Apps/Yogurt.app/Contents/MacOS/Yogurt')).toEqual({ execPath: '/usr/bin/open', args: ['-n', '-a', '/Users/sam/My Apps/Yogurt.app'] })
@@ -13,3 +13,18 @@ it('Linux starts the AppImage itself again: its mount goes away when Yogurt quit
expect(relaunchOptions('linux', true, '/tmp/.mount_abc/yogurt', '/home/sam/Yogurt.AppImage')).toEqual({ execPath: '/home/sam/Yogurt.AppImage' })
expect(relaunchOptions('linux', true, '/usr/bin/yogurt')).toBeUndefined()
})
+
+it('a relaunch forgets the library path that points into the AppImage mount it takes with it', () => {
+ const env = { APPDIR: '/tmp/.mount_abc', LD_LIBRARY_PATH: '/tmp/.mount_abc/usr/lib:/opt/lib' }
+ stripAppImageEnv(env)
+ expect(env.LD_LIBRARY_PATH).toBe('/opt/lib')
+ const onlyMount = { APPDIR: '/tmp/.mount_abc', LD_LIBRARY_PATH: '/tmp/.mount_abc/usr/lib' }
+ stripAppImageEnv(onlyMount)
+ expect(onlyMount.LD_LIBRARY_PATH).toBeUndefined()
+})
+
+it('a .deb or a dev run keeps the library path it was started with', () => {
+ const env = { LD_LIBRARY_PATH: '/opt/lib' }
+ stripAppImageEnv(env)
+ expect(env.LD_LIBRARY_PATH).toBe('/opt/lib')
+})