Skip to content

fix: rebuild re2 for x64 on arm64 macOS CI runner (fixes #3603)#3604

Merged
Yeraze merged 1 commit into
mainfrom
claude/great-dijkstra-7hs6rz
Jun 21, 2026
Merged

fix: rebuild re2 for x64 on arm64 macOS CI runner (fixes #3603)#3604
Yeraze merged 1 commit into
mainfrom
claude/great-dijkstra-7hs6rz

Conversation

@Yeraze

@Yeraze Yeraze commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #3603 — the macOS x64 DMG bundles re2.node as arm64, crashing on Intel Macs.

  • re2@1.25.0 uses install-artifact-from-github to fetch prebuilts. Unlike prebuild-install, it reads process.arch (always arm64 on the macos-14 runner), not npm_config_arch — so it downloads an arm64 binary regardless of the arch env vars set by the [BUG] MeshMonitor-Desktop-4.2.0-x64.dmg bundles better_sqlite3.node as arm64 instead of x86_64 #2901 fix.
  • After npm ci, the workflow now deletes the wrong arm64 re2.node and rebuilds it from source via node-gyp with CFLAGS/CXXFLAGS/LDFLAGS="-arch x86_64". Apple's clang supports this cross-compilation natively.
  • Also adds the missing npm_config_arch=x64 flags to desktop-ci.yml's x64 job (the release workflow had them; the CI workflow did not).

Test plan

  • Trigger a desktop-release.yml x64 macOS build and verify re2.node inside the DMG is x86_64 (file output in the build log should confirm this)
  • Install the resulting DMG on an Intel Mac and confirm the app starts without the ERR_DLOPEN_FAILED crash
  • Verify arm64 build is unaffected (that job runs natively on arm64 and is not modified)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kijmf1ZHtCJHuGWXV57hGc


Generated by Claude Code

re2@1.25.0 uses install-artifact-from-github to fetch prebuilt binaries.
Unlike prebuild-install, it reads process.arch (always arm64 on macos-14
runners) instead of npm_config_arch, so it downloads an arm64 re2.node
even when the arch env vars are set correctly.

After npm ci, delete the wrong arm64 binary and rebuild re2 from source
using node-gyp with CFLAGS/CXXFLAGS/LDFLAGS="-arch x86_64". Apple's
clang supports cross-compilation via -arch flags, so this produces a
correct x86_64 re2.node.

Also add the missing npm_config_arch=x64 flags to the desktop-ci.yml
x64 build job, which only had them in the release workflow.

Fixes #3603. See also #2901.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kijmf1ZHtCJHuGWXV57hGc
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown

Claude finished @Yeraze's task —— View job


PR Review

  • Gather context
  • Read changed workflow files
  • Analyze fix for correctness and best practices
  • Post review feedback

The fix is well-reasoned and correctly addresses the root cause. The install-artifact-from-github vs prebuild-install behavioral difference (reading process.arch instead of npm_config_arch) is real and this approach is the right workaround. Here are my observations:

What's Good

Correct diagnosis and fix. Deleting the wrong-arch re2.node and rebuilding from source using Apple's native cross-compilation (-arch x86_64) is the right approach for packages that bypass the npm arch env vars. The --arch=x64 flag to node-gyp plus the CFLAGS/CXXFLAGS/LDFLAGS trio covers both the compiler and linker.

Verification step. The file desktop/resources/dist/node_modules/re2/build/Release/re2.node echo + file output at the end of the step is excellent for debugging CI logs — it makes it immediately visible if the binary is the wrong arch.

Consistent application. The fix is applied to both desktop-ci.yml (lines 348–353) and desktop-release.yml (lines 738–743), which is necessary for both jobs to produce correct x64 builds.

Missing env vars fixed. Adding npm_config_arch=x64, npm_config_target_arch=x64, npm_config_platform=darwin, and npm_config_target_platform=darwin to desktop-ci.yml's build-macos-x64 job (lines 337–342) closes the gap with desktop-release.yml that had these for other packages.

Minor Issues / Observations

node-gyp path assumption (low risk, worth noting). The rebuild uses ../.bin/node-gyp (i.e., node_modules/.bin/node-gyp relative to the re2 package directory). This assumes node-gyp is installed as a direct dev dependency of the root project, which is typically true since node-pre-gyp and similar tools bring it in. If the dependency tree changes such that it's hoisted differently, this path could break. A more robust alternative would be npx node-gyp or an explicit $(npm root)/.bin/node-gyp, but since this has worked in node_modules layout for years it's unlikely to be a practical problem.

Re2 rebuild happens inline in "Prepare desktop resources". This means the file output confirming x86_64 appears in the same large step, not in its own named step. For CI observability, a dedicated step like "Rebuild re2 for x64" would make it easier to spot at a glance. Not blocking, just a UX suggestion.

desktop-ci.yml build-macos-x64 uses macos-14 explicitly (line 257) while build-macos uses macos-latest (line 141). This is intentional (macos-14 = arm64 for cross-compilation) and correct — worth keeping as-is.

No retry or error handling if node-gyp rebuild fails. If the rebuild fails (e.g., missing Xcode SDK for x86_64), the step will fail with a somewhat cryptic error. A || (echo "re2 rebuild failed"; exit 1) with a clear message could improve diagnostics — though this is a very minor enhancement.

Security

No concerns. The change only affects build tooling and does not modify application code, introduce new dependencies, or expose any credentials.

Test Plan Assessment

The proposed test plan is appropriate: verifying the file output in the build log (confirming x86_64) and testing on an actual Intel Mac. The build log already emits this via the echo "re2.node architecture after rebuild:" + file command, so half the test plan is automated.

Summary

This is a clean, targeted fix for a real cross-compilation issue with a tricky root cause. The only substantive suggestion is the node-gyp path robustness concern, which is low risk in practice. The PR is ready to merge.


@Yeraze Yeraze merged commit d244afb into main Jun 21, 2026
19 checks passed
@Yeraze Yeraze deleted the claude/great-dijkstra-7hs6rz branch June 21, 2026 17:42
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.11.2-x64.dmg bundles re2.node as arm64 instead of x86_64

2 participants