electron-builder: Builder in 25.0.0 finds files outside project and throws error
25.0.0
20.11.0
31.2.1 (current)
All, but testing on mac
Building in 24.x didn’t have this problem. I tried to upgrade and have an issue where the filter is throwing an error about files it finds even though they’re outside the directory where the build is happening (and also have all the dependencies set to no-hoist and that also didn’t work)
"**/electron-builder",
"**/app-builder-lib",
"**/builder-util",
"**/builder-util-runtime",
"**/dmg-builder",
Here’s the error stack for one iteration (I’ve tried a number of ways to do this. This stack is before I did nohoist. The question is: How can I set a relative directory for the file filter not to go above?
<PATH>/platform/build-dist/cloud/main/.env.cloud.defaults must be under <PATH>/platform/build-dist/desktop/main/app/
at getRelativePath (<PATH>/platform/node_modules/app-builder-lib/src/util/filter.ts:32:13)
at AsarPackager.unpackPattern (<PATH>/platform/node_modules/app-builder-lib/src/util/filter.ts:57:22)
at AsarPackager.createPackageFromFiles (<PATH>/platform/node_modules/app-builder-lib/src/asar/asarUtil.ts:130:82)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at AsarPackager.pack (<PATH>/platform/node_modules/app-builder-lib/src/asar/asarUtil.ts:50:41)
at <PATH>/platform/node_modules/app-builder-lib/src/platformPackager.ts:439:11
at async Promise.all (index 0)
at AsyncTaskManager.awaitTasks (<PATH>/platform/node_modules/builder-util/src/asyncTaskManager.ts:65:25)
at MacPackager.doPack (<PATH>/platform/node_modules/app-builder-lib/src/platformPackager.ts:293:5)
at MacPackager.pack (<PATH>/platform/node_modules/app-builder-lib/src/macPackager.ts:201:9)
at Packager.doBuild (<PATH>/platform/node_modules/app-builder-lib/src/packager.ts:458:9)
at executeFinally (<PATH>/platform/node_modules/builder-util/src/promise.ts:12:14)
at Packager.build (<PATH>/platform/node_modules/app-builder-lib/src/packager.ts:392:31)
at executeFinally (<PATH>/platform/node_modules/builder-util/src/promise.ts:12:14)```
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 16 (2 by maintainers)
@mmaietta It appears to be an issue caused by electron/asar integration.
copy file config
error info
https://github.com/electron-userland/electron-builder/blob/f84a0831d1d02b782ad07d4f7feff79d96dd45ec/packages/app-builder-lib/src/asar/asarUtil.ts#L103-L111
It shouldn’t consider everything outside of appDir as problematic. For example, in the issue above, it’s copying a pdfjs folder from outside the appDir, and within pdfjs there are some symlink files that point to files within the pdfjs folder itself.
patch
same too…
Try cleaning node_modules and cache. Helped me.
I’ve debugged it a bit, and seems like it was resolving symlinked to workspace1/node_modules from workspace2/ into actual folder path, than failing on validating it, `cos those folders are outside of project.
That would be easy to test by replacing symlinked modules with real copy of workspace2 into workspace1/node_modules - didn’t test it though.
Anyway, update to 26.0.11, full clean, npm i solved the issue.
We are still facing this issue on latest electron builder 26.0.11
@rathboma I’ve tested v25.1.8, and it’s been fixed. You can update your electron-builder version.
I can’t get it to happen in a small example. You can see the full project here: https://github.com/ulixee/platform/tree/main/desktop
The monorepo has a weird build process, which is probably why something is happening here that is out of the ordinary. We compile typescript into an entirely different directory and then builds node modules in that directory.
The desktop app is a submodule with a two app structure. So we have to actually copy over the project files so that the sub dependencies are found and packaged into the app.
I was trying out the new version because somehow only half of the native modules are added to asar unpacked. The latest version has the same problem - even though electron rebuilder shows them being rebuilt.