Some files are flagged as `unpack: true` in asar
I am trying to package my app for mac universal and the build fails on unpacking due to misconfigured flag unpack: true for the files.
Configuration
{
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/refs/heads/master/packages/app-builder-lib/scheme.json",
"framework": "electron",
"asar": true,
"productName": "...",
"files": ["out/**/*", "renderer/out/**/*", "!**/node_modules/{esbuild,@esbuild}/**/*"],
"afterSign": "./scripts/macos-notarize.cjs",
"afterPack": "./scripts/after-pack.cjs",
"afterAllArtifactBuild": "./scripts/after-all-artifact-build.cjs",
"mac": {
"extraFiles": ["./PrivacyInfo.xcprivacy"],
"target": ["dmg"],
"icon": "./renderer/out/branding/images/icon-1240x1240.png",
"category": "public.app-category.utilities",
"artifactName": "${productName}-${os}-${arch}-${version}.${ext}",
"electronLanguages": ["de", "de_DE"],
"mergeASARs": true,
"singleArchFiles": "...",
"extendInfo": {
"ITSAppUsesNonExemptEncryption": false
},
"x64ArchFiles": "..."
},
"mas": {
"type": "distribution",
"provisioningProfile": ".match/...",
"hardenedRuntime": false,
"entitlements": "variants/entitlements.mas.plist",
"entitlementsInherit": "variants/entitlements.mas.inherit.plist",
"entitlementsLoginHelper": "variants/entitlements.mas.loginhelper.plist"
},
"pkg": {
"scripts": "../../build/pkg-scripts",
"installLocation": "/Applications",
"allowAnywhere": true,
"allowCurrentUserHome": true,
"allowRootDirectory": true,
"isVersionChecked": false,
"isRelocatable": false,
"overwriteAction": "upgrade"
},
"win": {
"target": ["appx", "nsis"],
"icon": "./renderer/out/branding/images/icon-1024x1024.png",
"artifactName": "${productName}-${os}-${arch}-${version}.${ext}"
},
"linux": {
"target": "AppImage",
"artifactName": "${productName}-${os}-${arch}-${version}.${ext}",
"icon": "./renderer/out/branding/images/icon-1024x1024.png"
},
"nsis": {
"perMachine": true
},
"directories": {
"buildResources": "renderer/out/"
},
"extraMetadata": {
"productName": "ePA"
},
"asarUnpack": ["**/*.xsd"]
}
Depedencies
{
"@electron/fuses": "2.0.0",
"@electron/notarize": "3.0.1",
"electron": "37.2.4",
"electron-builder": "26.0.19",
"electron-better-ipc": "2.0.1",
"electron-devtools-installer": "4.0.0",
"electron-log": "5.4.2",
"electron-store": "10.1.0",
}
Build command
DEBUG=electron-builder electron-builder --config "./variants/default.config.json" --mac --universal
Output
Relevant Output
• packaging platform=darwin arch=universal electron=37.2.4 appOutDir=dist/mac-universal
⨯ ENOENT: no such file or directory, open '/var/folders/p0/mhwqr3n93zb3q_7rkz_0dp740000gn/T/electron-universal-HWw6YC/Tmp.app/Contents/Resources/app.asar.unpacked/out/.main/somexml.xml' failedTask=build stackTrace=Error: ENOENT: no such file or directory, open '/var/folders/p0/mhwqr3n93zb3q_7rkz_0dp740000gn/T/electron-universal-HWw6YC/Tmp.app/Contents/Resources/app.asar.unpacked/out/.main/some.xml'
at Object.openSync (node:fs:562:18)
at Object.readFileSync (node:fs:446:35)
at Object.readFileSync (/Users/.../git/work/.../node_modules/@electron/asar/src/disk.ts:198:17)
at Object.extractFile (/Users/.../git/work/.../node_modules/@electron/asar/src/asar.ts:346:15)
at mergeASARs (/Users/.../git/work/.../node_modules/@electron/universal/src/asar-utils.ts:148:29)
at makeUniversalApp (/Users/.../git/work/.../node_modules/@electron/universal/src/index.ts:275:23)
at MacPackager.doPack (/Users/.../git/work/.../node_modules/app-builder-lib/src/macPackager.ts:156:9)
at MacPackager.pack (/Users/.../git/work/.../node_modules/app-builder-lib/src/macPackager.ts:220:9)
at Packager.doBuild (/Users/.../git/work/.../node_modules/app-builder-lib/src/packager.ts:507:11)
at executeFinally (/Users/.../git/work/.../node_modules/builder-util/src/promise.ts:12:14)
After some digging I found out that files that throws ENOENT error are flagged by unpack: true during the unpack and hence not found.
For some reason xml, pem, cjs extensions are flagged as upacked even when they are not.
First off, thank you so much for a detailed issue report!
Looks like this error is coming from @electron/asar, but the unpack detection logic is indeed in electron-builder that is calling makeUniversalApp of @electron/universal
Would you be willing to put together a minimum repro repo for this so that I can quickly debug? I may need to fix a bug upstream if I can identify what's going wrong.
@mmaietta minimal repro: https://github.com/rajzik/electron-builder-repro
@mmaietta any update?
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment, or this will be closed in 30 days.
Can we keep this alive?
@rajzik are you still able to reproduce this on v26.3.0?
@mmaietta still the same error.
ENOENT: no such file or directory, open '/var/folders/p0/mhwqr3n93zb3q_7rkz_0dp740000gn/T/electron-universal-B7tUgw/Tmp.app/Contents/Resources/app.asar.unpacked/main/assets/b/b.xml' failedTask=build stackTrace=Error: ENOENT: no such file or directory, open '/var/folders/p0/mhwqr3n93zb3q_7rkz_0dp740000gn/T/electron-universal-B7tUgw/Tmp.app/Contents/Resources/app.asar.unpacked/main/assets/b/b.xml'
@mmaietta Update repro repo.
@mmaietta Any update on this one? Same issue on our end.
Well, I've verified my PR fixes the packaging issue, but I'm just struggling to figure out how to verify the change causes no issues with .framework file/folder/symlink structure during app runtime.