Commit c0149f7
authored
## Summary
Closes #176.
v0.1.3 on macOS Intel fails to open the snapshots DB with:
```
dlopen(...better_sqlite3.node-electron.node): (mach-o file, but is an
incompatible architecture (have 'arm64', need 'x86_64'))
```
### Diagnosis (scenario A)
- `electron-builder.yml` already declares `mac.target.arch: [arm64,
x64]`, and the v0.1.3 release assets include both
`open-codesign-0.1.3-arm64.dmg` and `open-codesign-0.1.3-x64.dmg`.
- Both DMGs were produced on a single `macos-latest` (arm64) runner.
- `apps/desktop/scripts/install-sqlite-bindings.cjs` stages per-arch
prebuilds plus a legacy alias `better_sqlite3.node-electron.node` that
points at the *host* arch. The runtime resolver in
`apps/desktop/src/main/snapshots-db.ts` prefers arch-specific files and
only falls back to the legacy alias when they are missing.
- The user's dlopen trace loads the legacy alias — meaning the
x64-specific file did not make it into the x64 DMG. electron-builder's
per-arch packaging pass reuses host-arch bytes for files it does not
know to re-stage, so the x64 DMG ships with arm64 bytes.
### Fix
Split the macOS build into native-arch runners and pin electron-builder
to each runner's host arch. Each runner does a fresh `pnpm install`, so
our postinstall stages the correct per-arch binaries and the legacy
alias matches the DMG arch.
- `macos-latest` (Apple Silicon) builds `--arm64` →
`open-codesign-*-arm64.dmg`
- `macos-13` (Intel) builds `--x64` → `open-codesign-*-x64.dmg`
Scope is limited to `.github/workflows/release.yml`. Runtime resolution
code and `electron-builder.yml` are unchanged.
### Principles check
- Compatibility: green — no format / schema changes.
- Upgradeability: green — future native-module additions inherit the
native-runner guarantee.
- No bloat: green — workflow only; one extra mac runner-minute per
release.
- Elegance: green — removes an implicit cross-build assumption.
## Test plan
Cannot fully verify locally (needs the full release workflow + published
artifacts). Required CI validation:
- [ ] Tag a prerelease (e.g. `v0.1.4-rc.1`) or dispatch the `Release`
workflow against a test tag.
- [ ] Confirm matrix runs `Build (macos-arm64)` on `macos-latest` and
`Build (macos-x64)` on `macos-13`, each finishing green.
- [ ] Download both DMGs from the artifacts / release.
- [ ] `hdiutil attach open-codesign-*-x64.dmg` and run `lipo -archs
'Open
CoDesign.app/Contents/Resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node-electron.node'`
→ expect `x86_64`.
- [ ] Repeat on the arm64 DMG → expect `arm64`.
- [ ] Launch x64 DMG on an Intel Mac (or VM): no "Could not open the
local snapshots database" banner.
Local CI signal: `pnpm lint` and `pnpm typecheck` both green on this
branch.
Signed-off-by: hqhq1025 <1506751656@qq.com>
1 parent 0ecef6a commit c0149f7
1 file changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 | | |
130 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
131 | 147 | | |
132 | 148 | | |
| 149 | + | |
| 150 | + | |
133 | 151 | | |
134 | 152 | | |
| 153 | + | |
| 154 | + | |
135 | 155 | | |
136 | 156 | | |
137 | 157 | | |
| |||
170 | 190 | | |
171 | 191 | | |
172 | 192 | | |
173 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
174 | 198 | | |
175 | 199 | | |
176 | 200 | | |
177 | 201 | | |
178 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
179 | 212 | | |
180 | 213 | | |
181 | 214 | | |
182 | | - | |
| 215 | + | |
183 | 216 | | |
184 | 217 | | |
185 | 218 | | |
| |||
0 commit comments