electron-builder: Unable to copy, file is symlinked outside the package
After I upgraded to v26, it throws error during build:
• electron-builder version=26.0.12 os=10.0.26100
• loaded configuration file=D:\Solutions\rho-meter\electron-builder.json
• writing effective config file=release\0.0.1\builder-effective-config.yaml
• skipped dependencies rebuild reason=npmRebuild is set to false
• packaging platform=win32 arch=x64 electron=35.1.5 appOutDir=release\0.0.1\win-unpacked
• custom electronDist provided but no zip found; assuming unpacked electron directory. electronDist=node_modules\electron\dist expectedFile=electron-v35.1.5-win32-x64.zip
• copying Electron source=D:\Solutions\rho-meter\node_modules\electron\dist destination=D:\Solutions\rho-meter\release\0.0.1\win-unpacked
⨯ unable to copy, file is symlinked outside the package source=node_modules\@serialport\bindings-cpp\prebuilds\win32-x64\node.napi.node realPathFile=node_modules\.pnpm\@serialport+bindings-cpp@12.0.1\node_modules\@serialport\bindings-cpp\prebuilds\win32-x64\node.napi.node
⨯ unable to copy, file is symlinked outside the package source=node_modules\@libsql\win32-x64-msvc\index.node realPathFile=node_modules\.pnpm\@libsql+win32-x64-msvc@0.5.4\node_modules\@libsql\win32-x64-msvc\index.node
⨯ Cannot cleanup:
Error #1 --------------------------------------------------------------------------------
Error: Cannot copy file (node.napi.node) symlinked to file (node.napi.node) outside the package as that violates asar security integrity
at writeFileOrProcessSymlink (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:126:15)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Promise.all (index 2)
at AsyncTaskManager.awaitTasks (D:\Solutions\rho-meter\node_modules\.pnpm\builder-util@26.0.11\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at AsarPackager.detectAndCopy (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:161:11)
at AsarPackager.pack (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:48:44)
at D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\platformPackager.ts:545:11
at async Promise.all (index 0)
at AsyncTaskManager.awaitTasks (D:\Solutions\rho-meter\node_modules\.pnpm\builder-util@26.0.11\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at WinPackager.doPack (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\platformPackager.ts:317:5)
Error #2 --------------------------------------------------------------------------------
Error: Cannot copy file (index.node) symlinked to file (index.node) outside the package as that violates asar security integrity
at writeFileOrProcessSymlink (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:126:15)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Promise.all (index 4)
at AsyncTaskManager.awaitTasks (D:\Solutions\rho-meter\node_modules\.pnpm\builder-util@26.0.11\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at AsarPackager.detectAndCopy (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:161:11)
at AsarPackager.pack (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\asar\asarUtil.ts:48:44)
at D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\platformPackager.ts:545:11
at async Promise.all (index 0)
at AsyncTaskManager.awaitTasks (D:\Solutions\rho-meter\node_modules\.pnpm\builder-util@26.0.11\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at WinPackager.doPack (D:\Solutions\rho-meter\node_modules\.pnpm\app-builder-lib@26.0.12_dmg_b995bd80b8ff3a8a64cee8adb9a5f824\node_modules\app-builder-lib\src\platformPackager.ts:317:5) failedTask=build stackTrace=Error: Cannot cleanup:
How do you think I could fix this? I’m using pnpm, thus the files in node_modules are all symlinks.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 25
Commits related to this issue
- fix: reversing symlink check logic and letting electron/asar determine if the symlink is invalid. Fixes #9025 — committed to electron-userland/electron-builder by mmaietta a year ago
I don’t see how that is anyone’s problem except for the developer using Electron. It shouldn’t be solved at this layer. It’s absurd that we cannot opt-in to using symlinks, or at least whitelist things. I’m not even using symlinks in my project… my project is just located in a path under a symlink, and yet now we’re stuck with this “security” warning.
Is there no way to disable this “enhancement”?
Yeah, this smells like a bug in electron-builder if
realpathSyncis resolving the issue for you. I’ll need to take a deeper look when I can find some time but am traveling for the next week@mmaietta I made a demo to reproduce it:
electron-builder-cp-file.patch
you can create an empty folder and apply this patch, then
pnpm i,npm run build, you should encounter this problem, then edit thepackages/app/build.jsfile:Execute
npm run buildagainI have the same issue as well. Is there a way to avoid this check altogether ? I don’t feel it’s necessary in my case
I am using the latest 26.0.15
For me, using this way makes it work:
The symlink check is enforced on the electron/asar side as well, so I think that’d be a no-go to exclude from our side, I just had wanted to provide a more specific error message https://github.com/electron/asar/blob/e4fb057678562b7b6170699a046d983ae6d31cb8/src/filesystem.ts#L159-L169
@kingyue737 Adding this check is to prevent some malicious packages from containing symbolic links to system files. I suggest replacing the file paths in “from” with real paths and avoid using symbolic links.
@mmaietta We should add some documentation to clarify that only real file paths can be used in “from,” and symbolic links are not allowed.