fix: use directory-level unpack patterns to avoid minimatch length limit#178
Open
akkay-fp wants to merge 3 commits intoelectron:mainfrom
Open
fix: use directory-level unpack patterns to avoid minimatch length limit#178akkay-fp wants to merge 3 commits intoelectron:mainfrom
akkay-fp wants to merge 3 commits intoelectron:mainfrom
Conversation
When merging ASARs for universal builds, the unpack pattern was
constructed by listing every individual unpacked file path in a brace
expansion like `{file1,file2,...}`. For projects with many unpacked
files (e.g. auto-unpacked native modules), this pattern can exceed
minimatch's 64 KiB limit, causing a "pattern is too long" TypeError.
This change groups unpacked files by their top-level directory (e.g.
`node_modules/pkg` or `dist/main`) and uses `**` glob patterns instead.
This reduces thousands of entries to a handful of directory patterns
while preserving the same unpack behavior.
Fixes electron-userland/electron-builder#7044
erickzhao
reviewed
Mar 10, 2026
src/asar-utils.ts
Outdated
| // listing every file individually. When there are many unpacked files | ||
| // (e.g. auto-unpacked native modules) the old brace-expansion approach | ||
| // can exceed minimatch's 64 KiB pattern-length limit. | ||
| // See: https://github.com/electron/universal/issues/XXX |
Member
There was a problem hiding this comment.
Do we have an open issue for this in the repo? Or was this supposed to link to the PR?
Author
There was a problem hiding this comment.
That was an oversight on my end. I haven't opened a separate issue because the PR description covers the problem comprehensively. I have updated the link to point here.
Author
|
@erickzhao I ran Prettier and pushed the latest changes to resolve the CI lint test case failures. Also, just a heads-up that the recent commit from @Akshay-akkay is from my personal GitHub account, as I was working on this from my own machine. Let me know if you need anything else! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When merging ASARs for universal macOS builds, the
unpackpattern passed toasar.createPackageWithOptionsis constructed by listing every individual unpacked file path in a brace expansion:{/tmp/x64-.../file1,/tmp/x64-.../file2,...}.For projects with many unpacked files (e.g. apps using native modules like
sharp,better-sqlite3,ag-psdthat get auto-unpacked by electron-builder'sdetectUnpackedDirs), this pattern can easily exceed minimatch's 64 KiB pattern length limit, causing:Fix
Instead of listing every individual file path, group unpacked files by their top-level directory (e.g.
node_modules/sharp,node_modules/@img/sharp-darwin-arm64,dist/main) and construct**glob patterns. This reduces thousands of entries to a handful of compact patterns while preserving identical unpack behavior.Before (3000+ files → ~400KB pattern):
After (6 directories → ~500 byte pattern):
Related Issues
app-builder-libin PR #8725, but the@electron/universalmergeASARscode path was not addressedTest Plan
sharp,better-sqlite3,ag-psd,fsevents,exiftool)--mac --universal) completes successfully with the fixDisclaimer: I took claude help for clean code comments and PR creation.
🤖 Generated with Claude Code