fix(desktop): build x64 macOS DMG with x64 native binaries#2912
Conversation
The build-macos-x64 job runs on macos-14 (arm64) and cross-compiles
the Tauri app for x86_64-apple-darwin. The npm ci step that installs
production deps into desktop/resources/dist did NOT specify a target
architecture, so prebuild-install (used by better-sqlite3 and other
native modules) downloaded prebuilt .node binaries for the host
arch (arm64) instead of the target arch (x64).
Result: MeshMonitor-Desktop-<version>-x64.dmg shipped with
better_sqlite3.node built for arm64. On Intel Macs the x64 app
fails to load it with ERR_DLOPEN_FAILED ("incompatible architecture
(have 'arm64', need 'x86_64')") and hangs at startup.
Set npm_config_arch=x64 / npm_config_target_arch=x64 /
npm_config_platform=darwin / npm_config_target_platform=darwin on
the bundle's npm ci so prebuild-install fetches darwin-x64 prebuilds.
The arm64 job (runs-on: macos-latest, also arm64) is unchanged —
host arch already matches target.
Fixes #2901
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @Yeraze's task —— View job PR Review Complete ✅Reviewing PR #2912: fix(desktop): build x64 macOS DMG with x64 native binaries Todo List:
✅ Overall Assessment: Excellent FixThis is a well-targeted, surgical fix that addresses the exact root cause of issue #2901. The solution is correct, secure, and follows best practices. 📋 Code Quality & Best Practices✅ Excellent:
✅ Good practices:
🐛 Potential Issues: None Found✅ No bugs identified:
⚡ Performance Considerations✅ No negative impact:
🔒 Security Assessment✅ Secure implementation:
🧪 Test Coverage Assessment
💡 Recommendations
🎯 Technical AccuracyThe fix correctly understands that:
✅ Final VerdictThis is a textbook example of a well-researched, precisely targeted fix. The implementation is correct, the documentation is thorough, and the approach follows industry best practices for cross-compilation scenarios. Approved for merge. |
Summary
Fixes #2901 —
MeshMonitor-Desktop-<version>-x64.dmgshipped abetter_sqlite3.nodebuilt for arm64, so the x64 app failed to start on Intel Macs withERR_DLOPEN_FAILED("incompatible architecture").Root cause
The
build-macos-x64job in.github/workflows/desktop-release.ymlruns onmacos-14(an arm64 GitHub runner) and cross-compiles the Tauri app forx86_64-apple-darwin. Thenpm cistep that installs production deps intodesktop/resources/distdid not set a target arch, soprebuild-install(used bybetter-sqlite3et al.) downloaded prebuilt.nodebinaries for the host arch (arm64) and bundled them into the x64 DMG.Fix
Force
prebuild-installto fetch x64 prebuilds by settingnpm_config_arch=x64,npm_config_target_arch=x64,npm_config_platform=darwin, andnpm_config_target_platform=darwinon the bundle'snpm ciinvocation in the x64 job. The arm64 job (also runs on an arm64 runner, builds for arm64 target) is unchanged — host arch already matches target.Test plan
MeshMonitor-Desktop-<version>-x64.dmgwhoseResources/dist/node_modules/better-sqlite3/build/Release/better_sqlite3.nodereportsMach-O 64-bit bundle x86_64viafileERR_DLOPEN_FAILEDinserver-stderr.log)🤖 Generated with Claude Code