Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): relaunch on Linux without setting no_new_privs #35173

ClosedTonybynMp4(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/35173/headopened View on GitHub

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

    1. 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.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -61,4 +76,14 @@
      6176 );
      6277
      6378 assert.strictEqual(systemLocale, "fr-FR");
      64- }).pipe(Effect.provide(ElectronApp.layer)),
      79+ }).pipe(Effect.provide(electronAppLayer)),
      80+ );
      81+
      82+ it.effect("relaunches through app.relaunch() off Linux", () =>
      83+ Effect.gen(function* () {
      84+ const electronApp = yield* ElectronApp.ElectronApp;
      85+ yield* electronApp.relaunch({ args: ["--flag"] });
      86+
      87+ assert.deepEqual(relaunchMock.mock.calls, [[{ args: ["--flag"] }]]);
      88+ }).pipe(
      89+ Effect.provide(electronAppLayer),
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This only mirrors a mock call for the unchanged non-Linux path. Could you delete this test?

      Posted via Macroscope — Test Signal
    4. Approvability

      Verdict: Approved at fea52e5

      Macroscope's review found this PR approvable — Linux restarts avoid Electron's inherited privilege restriction, allowing subsequent Debian updates to authenticate normally. Existing update controls remain intact, and non-Linux relaunch behavior is unchanged.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.