t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Nightly .758 still won't launch on macOS arm64 — @yuuang/ffi-rs-darwin-arm64 dropped from app.asar (#3790 didn't cover optional native deps)

Open Atchferox opened this issue 4 months ago • 2 comments

Area

Build, CI, or release tooling

Steps to reproduce

  1. Install T3 Code (Nightly) 0.0.29-nightly.20260708.758 on macOS arm64 (Apple Silicon).
  2. Launch it.

Or from a clean checkout at the .758 commit (0c6656585):

  1. pnpm install
  2. node scripts/build-desktop-artifact.ts --platform mac --target dir --arch arm64
  3. npx @electron/asar list "<built .app>/Contents/Resources/app.asar" | grep ffi-rs → ffi-rs is present, but its platform-specific optional dep is missing: ls "<built .app>/Contents/Resources/app.asar.unpacked/node_modules/@yuuang/" → No such file or directory

Expected behavior

App launches and opens a window.

Actual behavior

The backend child process crash-loops at startup (code=1) and no renderer is ever spawned — dock icon appears but no window opens. The backend dies on:

Error: Cannot find module '@yuuang/ffi-rs-darwin-arm64'
Require stack:
- /Applications/T3 Code (Nightly).app/Contents/Resources/app.asar/node_modules/ffi-rs/index.js

@yuuang/ffi-rs-darwin-arm64 (the native binary for ffi-rs, an optional platform-gated dependency) is dropped from the packaged app — the entire app.asar.unpacked/node_modules/@yuuang/ directory is absent.

Root cause (analysis)

This is the follow-on to #3789 / #3790, one dependency deeper.

  • #3772 bumped [email protected] → 11.10.0. pnpm ≥ 10.29.3 reports deduped deps differently (pnpm/pnpm#10601), and the electron-builder pnpm module collector silently drops those deps from app.asar.
  • #3790 bumped electron-builder 26.8.1 → 26.15.6, which restored the deduped prod deps (fixed the fast-check crash from #3789).
  • But ffi-rs's optional native dep @yuuang/ffi-rs-darwin-arm64 is still not collected into the asar, so .758 (which includes #3790) crashes on it instead. The collection fix didn't cover platform-gated optionalDependencies.

Confirmed by diffing the shipped bundles:

Build Relative to #3772 @yuuang/ffi-rs-darwin-arm64/ffi-rs.darwin-arm64.node in asar.unpacked
.751 before ✅ present
.758 after (+ #3790) ❌ absent

The dep is correctly declared in pnpm-lock.yaml (@yuuang/[email protected] as an optional of [email protected]), so this is a bundling/collection gap for optional native deps, not a missing declaration.

Impact

Blocks work completely

Version or commit

0.0.29-nightly.20260708.758 (0c6656585)

Environment

macOS (Apple Silicon / arm64), Darwin 25.5.0

Logs or stack traces

{"message":"backend child process output","level":"ERROR","annotations":{"component":"desktop-backend-child","stream":"stderr",
"text":"Error: Cannot find module '@yuuang/ffi-rs-darwin-arm64'\nRequire stack:\n- .../app.asar/node_modules/ffi-rs/index.js\n
    at Module._resolveFilename (node:internal/modules/cjs/loader:1483:15) ..."}}

Observed ~412 times (backend exits code=1 and respawns).

Workaround

Roll back to a nightly before #3772 (e.g. .751) and block auto-update: launchctl setenv T3CODE_DISABLE_AUTO_UPDATE 1 before relaunch.

Atchferox avatar Jul 08 '26 14:07 Atchferox

Confirming same for Windows

Error: Cannot find module '@yuuang/ffi-rs-win32-x64-msvc'

includenull avatar Jul 08 '26 15:07 includenull

Electron-builder mis-detects the staged app's package manager as npm (its pnpm workspace-root probe chokes on pnpm 11 stdout noise, then falls back to npm_config_user_agent, which vp exec doesn't set). The npm collector then drops optional dep subtrees from the asar. The npm_config_user_agent fix in #3816 resolves this, verified on mac arm64.

avocardow avatar Jul 09 '26 00:07 avocardow