Problem#
After the app restarts itself on Linux, a later .deb update fails with a generic "failed to quit and install" error. Electron's app.relaunch() starts the new instance with PR_SET_NO_NEW_PRIVS (electron/electron#41463). The flag is inherited and can't be cleared, so pkexec can't get privileges for the update. The same flag also breaks sudo in terminals the relaunched app starts.
Fix#
- Relaunch. On Linux,
ElectronApp.relaunch spawns a detached /bin/sh that blocks on its stdin until the parent exits, then execs the app with the same executable and args. Node's spawn doesn't set no_new_privs. If the spawn fails, it falls back to app.relaunch(). Other platforms are unchanged.
- AppImage. When running from an AppImage, it relaunches
$APPIMAGE, because the mount path disappears with the old process. Adapted from #27884.
.deb updates. The install no longer asks electron-updater to run the app afterwards (isForceRunAfter: false). The app relaunches through ElectronApp only after the install succeeds.
- Install errors. electron-updater emits an
error event synchronously from quitAndInstall and returns normally. ElectronUpdater.quitAndInstall now captures that event and fails with it, so a failed or cancelled install recovers the backend and update state without queuing a restart. This is the useful part of #15386, taken over by Julius.
Verification#
vp run check:changed passes (format, lint, knip, typecheck, tests for changed files).
- A real-process test checks that the relaunched process has
NoNewPrivs: 0. It is skipped off Linux and fails when the test runner itself has NoNewPrivs: 1, such as in some sandboxes.
- A harness test uses the installed
DebUpdater to check the success and failure paths of an install.
Not tested: a packaged build, a real .deb update, an AppImage relaunch, or the pkexec cancel prompt. Before merging, someone should run two .deb updates in a row on a packaged build.
A running instance that already has NoNewPrivs: 1 stays flagged. Its first update after this ships can still fail until the user quits and reopens T3 Code.
Closes https://git.cafe/pingdotgg/t3code/issues/27880, Closes https://git.cafe/pingdotgg/t3code/issues/14905, Closes pingdotgg/t3code#27880, Closes pingdotgg/t3code#14905
🤖 Generated with Claude Code
Closing: TonybynMp4 already has 3 or more open PRs here, which is the limit for contributors who are not vouched.
Once one of them is merged or closed, open this again. See the open PR limit.