Skip to content

fix(desktop): build x64 macOS DMG with x64 native binaries#2912

Merged
Yeraze merged 1 commit into
mainfrom
fix/desktop-mac-x64-arch
May 6, 2026
Merged

fix(desktop): build x64 macOS DMG with x64 native binaries#2912
Yeraze merged 1 commit into
mainfrom
fix/desktop-mac-x64-arch

Conversation

@Yeraze

@Yeraze Yeraze commented May 6, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #2901MeshMonitor-Desktop-<version>-x64.dmg shipped a better_sqlite3.node built for arm64, so the x64 app failed to start on Intel Macs with ERR_DLOPEN_FAILED ("incompatible architecture").

Root cause

The build-macos-x64 job in .github/workflows/desktop-release.yml runs on macos-14 (an arm64 GitHub runner) 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 set a target arch, so prebuild-install (used by better-sqlite3 et al.) downloaded prebuilt .node binaries for the host arch (arm64) and bundled them into the x64 DMG.

Fix

Force prebuild-install to fetch x64 prebuilds by setting npm_config_arch=x64, npm_config_target_arch=x64, npm_config_platform=darwin, and npm_config_target_platform=darwin on the bundle's npm ci invocation 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

  • Workflow run produces MeshMonitor-Desktop-<version>-x64.dmg whose Resources/dist/node_modules/better-sqlite3/build/Release/better_sqlite3.node reports Mach-O 64-bit bundle x86_64 via file
  • Install on Intel Mac, launch → app starts (no ERR_DLOPEN_FAILED in server-stderr.log)
  • arm64 DMG remains arm64 and continues to launch on Apple Silicon

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

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:

  • Read and analyze the workflow file changes
  • Review the fix against the stated problem
  • Check for code quality and best practices
  • Identify potential bugs or issues
  • Assess security considerations
  • Provide comprehensive feedback

Overall Assessment: Excellent Fix

This 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:

  • Precise targeting: Fix is applied only to the build-macos-x64 job where the problem occurs
  • Clear documentation: Comprehensive inline comments (lines 684-687) explain the why and reference the issue
  • Consistent approach: Mirrors the Windows job pattern but adapts for the cross-compilation scenario
  • Minimal impact: Changes only what's necessary without affecting other jobs

✅ Good practices:

  • Uses standard npm configuration variables recognized by prebuild-install
  • Maintains consistency with existing step structure
  • Comments explain the cross-compilation context clearly

🐛 Potential Issues: None Found

✅ No bugs identified:

  • Environment variable syntax is correct for npm
  • All four required variables are properly set (arch, target_arch, platform, target_platform)
  • Command structure remains identical to working pattern elsewhere

Performance Considerations

✅ No negative impact:

  • No additional download overhead (still fetching the same number of binaries)
  • May slightly improve performance by ensuring correct architecture match
  • Build time should remain the same

🔒 Security Assessment

✅ Secure implementation:

  • No new external dependencies or downloads
  • Uses standard npm configuration mechanism
  • No secrets or credentials exposed
  • Environment variables are locally scoped to the npm command

🧪 Test Coverage Assessment

⚠️ Suggestion for improvement:
The test plan in the PR description is appropriate but could benefit from:

  • Automated verification that the bundled .node files are actually x64 architecture
  • Consider adding a step to verify binary architecture using file command in CI

💡 Recommendations

  1. Optional Enhancement: Consider adding architecture verification to CI:

    - name: Verify x64 architecture
      run: |
        find desktop/resources/dist/node_modules -name "*.node" | head -5 | while read file; do
          echo "Checking $file:"
          file "$file"
        done
  2. Documentation: This fix could be documented in the repository to help future maintainers understand the cross-compilation nuances.

🎯 Technical Accuracy

The fix correctly understands that:

  • macos-14 runners are ARM64 architecture
  • prebuild-install defaults to host architecture when no target is specified
  • Cross-compilation requires explicit architecture targeting for native dependencies
  • The four npm config variables are the standard approach for this scenario

Final Verdict

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


@Yeraze Yeraze merged commit 19f2f6f into main May 6, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MeshMonitor-Desktop-4.2.0-x64.dmg bundles better_sqlite3.node as arm64 instead of x86_64

1 participant