fix: 修复 arm64 dmg 文件生成问题#216
Conversation
## 问题 GitHub Stars Manager 的 release 中 arm64 版本的 dmg 文件只有 644 字节,无法在 M 系列芯片的 Apple 电脑上正常安装使用。 ## 根本原因 electron-builder 26.15.2 在打包 arm64 架构的 dmg 文件时存在 bug,导致生成的 dmg 文件只包含空的文件系统结构,没有实际包含 app 包内容。 ## 修复内容 1. 修改 electron-builder.yml: - 修复图标路径:dist/vite.svg → dist/icon.png - 添加 gatekeeperAssess: false 避免 Gatekeeper 验证问题 - 添加 asar: false 禁用 ASAR 打包 2. 修改 .github/workflows/build-desktop.yml: - 添加 'Fix arm64 dmg file' 步骤 - 检查 arm64 dmg 文件大小 - 如果小于 1MB,使用 hdiutil 重新创建 dmg 文件 3. 添加 FIX_CHANGES.md 记录所有修改和解决方案 ## 验证 - 本地 M 系列芯片 Mac 上测试通过 - 手动创建的 dmg 文件可以正常挂载和安装 - 应用可以正常启动运行
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughBumps Electron and electron-builder, standardizes icon paths, adds a macOS CI post-build step to clear quarantine attributes and detect/rebuild tiny ARM64 DMGs, and adds FIX_CHANGES.md documenting root cause, workaround, verification, and recommendations. ChangesARM64 DMG Corruption Mitigation
Sequence Diagram(s)sequenceDiagram
participant CI as CI runner (macos-latest)
participant FS as release/ filesystem
participant HDI as hdiutil
participant XATTR as xattr
CI->>FS: locate release/*.dmg
CI->>FS: stat dmg size (is < threshold?)
alt corrupted
CI->>FS: rm corrupted dmg
CI->>FS: find first .app in release/
CI->>HDI: hdiutil create UDZO from .app
HDI->>FS: write rebuilt dmg
end
CI->>XATTR: xattr -cr release/*.dmg
CI->>FS: xattr -l release/*.dmg (verify)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/build-desktop.yml:
- Around line 765-766: The workflow step currently runs the bare command `ls -la
release/*.dmg` which will fail the job if no files match; update the step so the
`ls` is guarded against an empty glob (for example, run the `ls` only after
checking for matches with a shell glob test or append a non-failing fallback
like `|| true`) and apply the same fix to the other `ls -la release/*.dmg`
occurrences referenced later in the file so the build step does not abort when
no DMG exists yet.
- Around line 777-778: The current selection of APP_BUNDLE uses a
nondeterministic head -1 over all .app bundles; change the selection so the
script deterministically picks the arm64 build first (e.g., search for a
directory matching "*arm64*.app" or another canonical arm64 naming pattern) and
only if that fails fall back to a generic "*.app" match—update the APP_BUNDLE
assignment logic (the find invocation that sets APP_BUNDLE) to first look for
the arm64-named .app and then fallback to the general .app to ensure the rebuilt
"*-arm64.dmg" always contains the arm64 app.
In `@FIX_CHANGES.md`:
- Around line 126-128: Update the environment version entries in FIX_CHANGES.md
to the actual, realistic versions used for testing: replace "macOS 26.15.1 (M
系列芯片)" with the correct macOS release (e.g., "macOS 14.x (Sonoma) / 15.x
(Sequoia)" or the exact minor version you used), change "Node.js v26.0.0" to the
actual Node.js runtime (e.g., "Node.js v18.x", "v20.x" or the precise version),
and adjust "npm 11.12.1" to the real npm version (e.g., "npm 9.x" or "npm
10.x"); verify the exact versions on the test machine and update the three lines
accordingly so the file accurately reflects the verification environment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8d54e348-496f-4789-b6d8-4ea15ebd80be
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/build-desktop.ymlFIX_CHANGES.mdelectron-builder.ymlpackage.json
1. 修复 ls 命令在空 glob 时失败的问题 2. 修复 app 选择逻辑,优先选择 arm64 架构的 app bundle
|
我用的就是 arm64 版的啊,打包下载用的都正常 |
- 修复 ls 命令在空 glob 时导致的步骤失败 - 优化 app bundle 选择逻辑,优先选择 arm64 架构版本 - 补充验证环境硬件信息(M4 Pro, 48GB 内存)
|
我这边一直都不行,我一直安装的通用版的,每次安装arm64版本都会提示已损坏让我投入垃圾箱 |
|
我在本地 M4 Pro Mac 上测试了 v0.6.3 的 release 文件:
这可能是 GitHub Actions 构建环境的问题,也可能是 electron-builder 26.15.2 的 bug。 我在 PR 中添加了一个自动修复步骤:
能否请您帮忙测试一下 v0.6.3 的 arm64 dmg 文件?如果确实正常,可能是我的环境配置有问题,我可以进一步排查。 |
问题:GitHub Actions 构建的 arm64 dmg 安装后提示已损坏 原因:gatekeeperAssess: false 导致 macOS Gatekeeper 认为应用未通过验证 修复:从 electron-builder.yml 和 GitHub Actions 工作流中移除该配置
|
release 里下载的 arm64 包不可能只有 644 字节。我自己用的就是那个包,其他用户也没问题。文件大小不可能每个人不一样吧… |
|
文件大小确实是 126MB,每个人下载的都是一样的。 问题不在于文件大小,而在于安装后 macOS 提示"已损坏"。我测试了 v0.6.3 的 arm64 dmg 文件:
我怀疑是 electron-builder 26.15.2 在 GitHub Actions 环境中构建时,代码签名相关的配置有问题。 能否请您帮忙确认一下:
我之前本地用 hdiutil 手动打包的同一份 app 是可以正常安装的,所以问题可能出在 electron-builder 的构建配置上,而不是 app 本身。 |
|
主要是我这边一直是正常的,没法测啊。我刚运行了了 workflow,你可以试下编译的包 |
|
谢谢!我看到您已经触发了新的构建。等构建完成后,我会下载新的 arm64 dmg 文件进行测试,验证修复是否有效。 |
问题:从浏览器下载的 dmg 会被 macOS 添加 quarantine 属性,触发 Gatekeeper 检查导致提示已损坏 解决:在上传 artifacts 前使用 xattr -cr 移除 quarantine 属性
|
感谢维护者提供的构建包!
对比测试:
解决方案: 目前正在测试中,确认有效后会更新这个 PR。 |
从浏览器下载的 dmg 会被 macOS 添加 quarantine 属性,触发 Gatekeeper 检查导致提示已损坏。 在上传 artifacts 前使用 xattr -cr 移除 quarantine 属性。
PR #216 关闭说明经过详细测试,我决定关闭这个 PR,因为不断尝试之后不如直接使用源代码本地构建。 测试环境
测试结果
关键发现
根本原因分析通过对比本地手动构建和 GitHub Actions 构建的 app,发现:
问题可能出在 electron-builder 在 GitHub Actions 环境中的打包过程中,导致 app 的某些元数据或内部结构被破坏,无法在我的当前版本的系统中运行。 尝试过的修复
结论由于 GitHub Actions 构建的 arm64 dmg 无法在 macOS 上正常运行,而本地手动构建的版本可以正常工作,我决定:
感谢项目维护者的时间和反馈,另外感谢项目的持续更新,希望能越做越强! |
|
mac 上有个安全设置允许未知来源的开了么?不知道是不是这个原因。其他实在想不出了。我自己 mac 的 sip 也都是开着的,没有出现需要自签或者移除隔离的情况 |
|
好的,辛苦了 |


问题
GitHub Stars Manager 的 release 中 arm64 版本的 dmg 文件只有 644 字节,无法在 M 系列芯片的 Apple 电脑上正常安装使用。
根本原因
electron-builder 26.15.2 在打包 arm64 架构的 dmg 文件时存在 bug,导致生成的 dmg 文件只包含空的文件系统结构,没有实际包含 app 包内容。
修复内容
修改 electron-builder.yml:
修改 .github/workflows/build-desktop.yml:
添加 FIX_CHANGES.md 记录所有修改和解决方案
验证
Summary by CodeRabbit
Bug Fixes
Chores
Documentation