`pattern is too long` minimatch error during `electron/universal` auto-detect unpack logic
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- electron, typescript
- Domain
- build-system, desktop-dev
Research direction
Start by reading src/asar-utils.ts around lines 96-109 and src/asar.ts around lines 92-95 to understand the ordering and unpack-detection paths. Inspect the linked electron/asar PR #350 and reproduce the universal build with realm if needed. Done means the universal build no longer fails with minimatch's “pattern is too long” error.
Written by the indexing model from the issue text.
Description
Hello all, I've encountered this bug repeatedly on universal builds
The issue seems to stem from the electron/universal unpack detection.
⨯ pattern is too long failedTask=build stackTrace=TypeError: pattern is too long
at assertValidPattern (/Users/mikemaietta/Development/electron-builder-test/node_modules/minimatch/minimatch.js:279:11)
at minimatch (/Users/mikemaietta/Development/electron-builder-test/node_modules/minimatch/minimatch.js:116:3)
at shouldUnpackPath (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/asar/src/asar.ts:152:8)
at handleFile (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/asar/src/asar.ts:171:22)
at next (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/asar/src/asar.ts:199:5)
at createPackageFromFiles (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/asar/src/asar.ts:203:2)
at Object.createPackageWithOptions (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/asar/src/asar.ts:57:10)
at mergeASARs (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/universal/src/asar-utils.ts:215:5)
at makeUniversalApp (/Users/mikemaietta/Development/electron-builder-test/node_modules/@electron/universal/src/index.ts:245:7)
Steps to repro:
- Install
realmto electron-quick-start project - Assemble project with electron-builder (which internally uses electron/asar) using
universaltarget
Internal logic:
- electron-builder is executing
electron/asarwith unpack minimatch (logged from withinelectron/asar'sshouldUnpackPathinternal function for debugging purposes')
{node_modules/realm,/private/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/t-wh5lzR/asar-app-2/node_modules/realm/prebuilds/node/realm.node}
- 2 asars are successfully generated with electron/asar
- execute
electron/universalon the two.apps.What seems to happen is thatelectron/universalis autodetecting what to unpack, and passes in a minimatch with over 2.8k minimatch entries
https://github.com/electron/universal/blob/caa0567b76bc06d0014e6fc5afb6d70d47651971/src/asar-utils.ts#L96-L109
Excerpt:
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/PrivacyInfo.xcprivacy
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/RealmJS.podspec
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/bindgen/src/realm_js_jsi_helpers.h
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/bindgen/src/realm_js_node_helpers.h
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/bindgen/vendor/realm-core/bindgen/src/realm_helpers.h
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/CMakeLists.txt
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/build.gradle
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/settings.gradle
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/AndroidManifest.xml
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/cpp/io_realm_react_RealmReactModule.cpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/cpp/jni_utils.cpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/cpp/jni_utils.hpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/cpp/platform.cpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/java/io/realm/react/RealmReactModule.java
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/java/io/realm/react/RealmReactPackage.java
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/android/src/main/java/io/realm/react/util/SSLHelper.java
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/apple/RealmReactModule.h
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/apple/RealmReactModule.mm
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/apple/platform.mm
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/jsi/jsi_externs.hpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/jsi/jsi_init.cpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/jsi/jsi_init.h
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/jsi/react_scheduler.cpp
/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/x64-w0n63V/node_modules/realm/binding/jsi/react_scheduler.h
...waaaay more entries like this
Proposed resolution options:
- Only pass in the common root folder of each File Set (in this case
/node_modules/realm) to minimatch (this requires changes to electron/universal detection logic) - Bypass minimatch with more explicit control over packaging options, similar as to asar ordering logic. (requires changes in electron/asar) Options:
a. Implement property that allows us to passunpackPaths: string[]which allows explicit control
b. Leverageoptions.orderingconfiguration ofelectron/asarto pass in JSON config for each file to be unpacked
Personally, I'd highly advocate for 2b, as it's relatively light of a change that is not breaking. AND it also makes sure this minimatch pattern is too long issue won't be ever be a roadblock for advanced users. electron-builder has a very complex copy-unpack-detection logic flow and we've hit the pattern is too long a few times previously, which we solved by implementing the approach of #1 before passing the unpack minimatch into electron/asar, but I can imagine this issue will be hit again if I'm just receiving it on electron/universal for an electron-quick-start project installing only realm.
Implementation Proposal:
Right now, the "ordering" file is simply of format:
<file name>:<anything>
Right now, electron/asar only pulls the filename value before the :
https://github.com/electron/asar/blob/121efebd2d02e374713cb513eb56a0e3db9534e9/src/asar.ts#L92-L95
The proposal is to leverage <anything> to be JSON.stringify of Type:
{
unpack: boolean // the required property for resolve this issue
// allows for future properties to be added for advanced usage without a breaking change
}
Taking this approach allows future configuration options to be allowed on a per-file basis should electron/asar need/desire to support more advanced usage
[UPDATE] PR Fix https://github.com/electron/asar/pull/350
- Dominant language
- TypeScript
- Stars
- 148
- Forks
- 48
- Avg merge
- 3h 57m
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from electron/universal
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
All issues in electron/universal
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·