t3code icon indicating copy to clipboard operation
t3code copied to clipboard

AppImage update deletes the old binary before mv; a failed mv (ENOTCONN from stale mount on PATH) leaves no app

Open Derpedyea opened this issue 1 month ago • 1 comments

What happened

T3code simply won't start

The Linux AppImage desktop app installed a nightly update and never came back. Launching it afterwards fails right away because the AppImage file no longer exists:

~/.local/bin/t3-code: line 9: ~/.local/opt/t3-code/T3-Code.AppImage: No such file or directory   (exit 127)

Diagnosis

electron-updater's AppImage install isn't atomic. It deletes the running AppImage first and only then moves the new one into place with mv, which it finds through a PATH lookup ([email protected], out/AppImageUpdater.js):

(0, fs_1.unlinkSync)(appImageFile);                                  // line 81
...
(0, child_process_1.execFileSync)("mv", ["-f", installerPath, destination]); // line 98

If the mv fails for any reason, the user is left with no AppImage at all. Here's what happened on this machine:

  1. Update 0.1.2-nightly.20261021.3499 downloaded and passed its sha512 check (~/.cache/t3code-updater/pending/).
  2. Install attempt 1: unlinkSync succeeded, then execFileSync("mv") failed with spawnSync mv ENOTCONN.
  3. recoverFailedInstall (apps/desktop/src/updates/DesktopUpdates.ts:656) reset state, but it can't bring back the deleted file.
  4. Install attempt 2: unlink … ENOENT. The app then quit and couldn't be launched again.

Probable cause of the ENOTCONN (inferred, not reproduced in isolation): a dead AppImage FUSE mount from an earlier launch (~/.cache/t3code/tmp/.mount_T3-CodKBflMf, still listed in mount but returning "Transport endpoint is not connected") was on the desktop process's PATH. That's the same mechanism as #18790: PATH lookup stops at the first ENOTCONN, before /usr/bin/mv. #18808 fixed this for the server env. The updater's mv runs in the Electron main process, which still inherits the stale PATH.

Suggested fixes (either one would have prevented this):

  • Don't let a failed mv destroy the install: stage the new file next to the target and rename() it over the old one (atomic, no child process). Alternatively, keep the old file until the move succeeds.
  • Strip dead or foreign .mount_* entries from the main process's process.env.PATH at startup, not only from the spawned server env.

Steps to reproduce

Deterministic repro not run. Conditions seen here:

  1. Linux, desktop AppImage on the nightly channel, launched several times so that an earlier launch's .mount_T3-Cod* dir is still on PATH and that mount has died.
  2. Let an update download, then click install.
  3. Expected: the new AppImage replaces the old one. Actual: the old AppImage is deleted, mv fails with ENOTCONN, and there is no AppImage left on disk.

Likely minimal repro of the non-atomic step: put a directory that returns ENOTCONN (a killed FUSE mount) ahead of /usr/bin on PATH, then trigger quitAndInstall.

Version

0.1.2-nightly.20261021.3486 (the build that was running, from service.version in the server trace), updating to 0.1.2-nightly.20261021.3499. The triage CLI was 0.1.2-nightly.20261021.3499.

Environment

CachyOS Linux x64, kernel 7.2.10-1-cachyos, Node v26.8.2. Desktop AppImage launched through a wrapper script that sets TMPDIR=~/.cache/t3code/tmp.

Evidence

# desktop.trace.ndjson
20:20:27  desktop.updates.install
20:20:28  desktop.updates.handleUpdaterError  cause="Error [ENOTCONN]: spawnSync mv ENOTCONN"  operation=install
20:22:21  desktop.updates.install
20:22:21  desktop.updates.handleUpdaterError  cause="Error [ENOENT]: ENOENT: no such file or directory, unlink '~/.local/opt/t3-code/T3-Code.AppImage'"  operation=install

# journalctl, next launch
20:22:29  t3-code: ~/.local/bin/t3-code: line 9: ~/.local/opt/t3-code/T3-Code.AppImage: No such file or directory
          status=127

$ ls ~/.cache/t3code/tmp/.mount_T3-CodKBflMf
ls: cannot access ...: Transport endpoint is not connected

Related issues

  • #18790 / #18808: same stale-mount ENOTCONN mechanism, fixed for the server env only. This report is about the updater in the main process.
  • #10685: AppImage update left a 0-byte binary (closed, not planned). Same symptom ("app never launches after update"), different failure.

Fix applied or workaround

  1. fusermount3 -uz on the dead .mount_T3-Cod* dir.
  2. Copied the verified pending download into place: install -m755 ~/.cache/t3code-updater/pending/T3-Code-0.1.2-nightly.20261021.3499-x86_64.AppImage ~/.local/opt/t3-code/T3-Code.AppImage.

Filed by

Claude Code (claude-opus-5-5) via t3 triage

Derpedyea avatar Oct 22 '26 01:10 Derpedyea

The destructive AppImage replacement path is already tracked in #10685. Its open fix stack, #21621 and #21622, stages and verifies the replacement beside the destination, then commits it with a rename instead of deleting the working AppImage and invoking mv through PATH. That covers the missing-binary failure here as well as the partial-copy failure in the original report. The ENOTCONN trigger is new evidence for the same unsafe replacement path; it was not independently reproduced during this duplicate check. Closing as a duplicate to keep the fix in one place.

juliusmarminge avatar Oct 22 '26 01:10 juliusmarminge