Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electron-builder fails when list of node_modules files is too big to pass in a glob #8705

Open
abram opened this issue Nov 22, 2024 · 3 comments · May be fixed by #8725
Open

electron-builder fails when list of node_modules files is too big to pass in a glob #8705

abram opened this issue Nov 22, 2024 · 3 comments · May be fixed by #8725

Comments

@abram
Copy link

abram commented Nov 22, 2024

This recent change causes electron-builder to fail in my project:

const unpackGlob = unpackedPaths.length > 1 ? `{${unpackedPaths.join(",")}}` : unpackedPaths.pop()

It attempts to take a potentially large file list and put it into a glob pattern string. This causes an error due to exceeding a hard coded limit in minimatch:

pattern is too long
    at assertValidPattern (node_modules\minimatch\minimatch.js:280:11)
    at minimatch (node_modules\minimatch\minimatch.js:116:3)
    at isUnpackedDir (node_modules\@electron\asar\src\asar.ts:24:41)
    at handleFile (node_modules\@electron\asar\src\asar.ts:148:17)
    at next (node_modules\@electron\asar\src\asar.ts:185:5)
    at AsarPackager.executeElectronAsar (node_modules\app-builder-lib\src\asar\asarUtil.ts:77:5)
    at AsarPackager.pack (app-builder-lib\src\asar\asarUtil.ts:51:5)

You can see the limit code here:
https://github.com/isaacs/minimatch/blob/main/src/assert-valid-pattern.ts#L1

I'm not familiar with the asar module, but there must be a better way to pass a file list than using a giant glob.

@beyondkmp
Copy link
Collaborator

#8645 can fix this issue. It only add the node_modules/xxx into unpackedPaths intead of all sub directories in node_modules/xxx.

@beyondkmp
Copy link
Collaborator

@abram This #8645 has been merged into v26.0.0-alpha.7. Can you help try it?

@abram
Copy link
Author

abram commented Dec 5, 2024

Thanks for your work @beyondkmp!

Unfortunately, after upgrading to v26.0.0-alpha.7, I still get the "pattern is too long" error when running electron-builder dist for my project.

I created a demo repo here: https://github.com/abram/electron-builder-pattern-too-long-error-demo

Can you try checking that out and see if you're able to reproduce the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants