Open kochizufan opened 8 months ago
This issue occurs due to a lack of administrator privileges. If you are using an editor like VS Code, run it with administrator privileges.
Alternatively, you can run the command directly in CMD or PowerShell, but make sure to open them as Administrator to avoid permission issues.
Ex:
This error is happening in our CI where running as administrator is not allowed. Is there a workaround for running as an unprivileged user?
I also encountered this issue and solved it using 'PowerShell with ADMINISTRATOR' But I didn't see any prompts about building Windows on the official website. Is this the correct operation?
FYI, it seems like it's an issue with the 7zip upgrade under the hood. Workaround: downgrade to electron-builder@24.6.3
.
I've the same issue. There is maybe a better workaround available:
Download the winCodeSign.7z package manually. You can use the same URL as electron-builder is using: https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z
Then extract the archive to the requested location (I've used 7-Zip 23.01 for Windows) so that you have this folder on your machine:
C:\Users\<YourUserName>\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\
That's it. I got no errors during extraction. Once the folder exists the download and extraction of the 7z file is skipped during the electron-builder run.
Pro:
Con
I got 2 errors after extraction:
Cannot create symbolic link : A required privilege is not held by the client. : c:\users[username]\appdata\local\electron-builder\cache\wincodesign\wincodesign-2.6.0\darwin\10.12\lib\libcrypto.dylib Cannot create symbolic link : A required privilege is not held by the client. : c:\users[username]\appdata\local\electron-builder\cache\wincodesign\wincodesign-2.6.0\darwin\10.12\lib\libssl.dylib
We are experiencing this issue as well, downgrading to electron-builder@24.6.3 helped, for now. Hopefully this can be resolved. The downgrade diff does indeed show that the 7zip dependency has also been downgraded, so I wonder if it would help to pin it to the old version using resolutions, if someone actually needs to be on the latest electron-builder until this is resolved.
This problem is due to privilege. The solution is simple, just open your project folder in CMD or PowerShell with ADMINISTRATOR privileges.
Ex:
Thanks it worked for me. I have tried many ways done its working fine
also solved by running as Admin privileged user, unfortunately workarounds with fixing the 7z version were not helpful for me...
the archive just needs to repacked by electron-builder without the links .. so whatever is used to create the archive in the first place includes the option to archive symlinks ... which is not default behaviour of 7z
Also hit this issue. Worked around by running Powershell as admin. Would love to see this fixed properly.
the archive just needs to repacked by electron-builder without the links .. so whatever is used to create the archive in the first place includes the option to archive symlinks ... which is not default behaviour of 7z
The symlinks are due to the downloader downloading Mac app bundles on Windows. Those symlinks are required for Mac apps to work, but AFAIK there's no reason for the Windows downloader to be downloading Mac build assets. If the downloader only downloaded what it needed, this would not be a problem at all for most users (assuming there's a legitimate reason for this download to be happening in the first place).
FYI - I ran into this issue as well. Rather than downgrading, I upgraded to the latest version (25.0.5 currently) as there's a note in the recent changelogs about symlinks, but the issue is still present (windows 11). I followed the instructions above about manually downloading the zipfile and extracting all contents to the electron-builder\cache\winCodeSign folder and it worked perfectly so thanks for that solution, @renkei!
I tried using 7zip 23.01 and 24.08, nothing worked.
I downloaded the winCodeSign-2.6.0's source code from https://github.com/electron-userland/electron-builder-binaries/releases/tag/winCodeSign-2.6.0
Then navigated to: C:\Users\<Your UserName>\Downloads\electron-builder-binaries-winCodeSign-2.6.0.zip\electron-builder-binaries-winCodeSign-2.6.0\winCodeSign
Copied all the contents and pasted it inC:\Users\<YourUserName>\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\
Doing this worked for me! I don't have the administrator access, yet I'm able to get the files from the source code (zip) rather than the 7zip file, so it's working just fine!
Thanks to @renkei for your amazing answer! able to sort this issue out. I guess it's some problem with 7zip itself because I was not able to extract manually too.
Hey all, returning to this issue. Am I understanding this correctly? The 7zip file isn't properly able to be extracted or is running into an issue due to the upgrade that occurred in this PR? https://github.com/electron-userland/electron-builder/pull/7829
Wondering if this binary (that created the winCodeSign 7z file) needs to be updated: https://github.com/electron-userland/electron-builder-binaries/blob/master/7za
Hey all, returning to this issue. Am I understanding this correctly? The 7zip file isn't properly able to be extracted or is running into an issue due to the upgrade that occurred in this PR? #7829
Wondering if this binary (that created the winCodeSign 7z file) needs to be updated: https://github.com/electron-userland/electron-builder-binaries/blob/master/7za
The bug is caused by the confluence of 2 factors:
7zip-bin
upgrade now attempts to create symlinks on Windows, which requires administrator privileges. Historically, libraries got around this by using hardlinks, but I guess that's not the case anymore.electron-builder
itself is only extracting these symlinks on Windows in the first place because it's trying to extract Mac-specific build assets that make heavy use of symlinks. electron-builder
stopped trying to unzip .app
folders or whatever on Windows (there's literally no reason to do this) then the issue would be resolved.winCodeSign
only downloaded what it needs based on the electron-builder config.)This should involve releasing winCodeSign for mac/win/linux in electron-builder-binaries based on the system, then downloading the appropriate version for the specific system being used.
Another option is to see if parameters can be added during 7z extraction to convert symbolic links to hard links.
Another option is to see if parameters can be added during 7z extraction to convert symbolic links to hard links.
node_modules/7zip-bin/mac/arm64/7za -h
7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,12 CPUs LE)
Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
<Switches>
-- : Stop switches parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
-v{Size}[b|k|m|g] : Create volumes
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
Hmmmm, so there's a manner with which to avoid using 7zip-bin altogether is by using env var USE_SYSTEM_7ZA=true
, it seems that can override 7zip-bin
https://github.com/develar/7zip-bin/blob/234abf56ddc2935de44e07d5e3c40eecab95d5af/index.js#L5-L8
Might be worth trying that out and test if a newer version of 7za resolves the issue for you?
If it does, then I'd imagine this workaround would no longer be needed https://github.com/electron-userland/electron-builder/issues/8149#issuecomment-2079252400 and we can proceed with opening a PR upstream for 7zip-bin. There's coincidentally a vulnerability reported https://github.com/develar/7zip-bin/issues/26 that requires it to be updated anyhow.
FWIW, I've started working on getting 7zip updated. https://github.com/develar/7zip-bin/tree/update-7zip
Few tests are failing for electron-builder with that specific branch, so far I have needed to remove a -mcu
switch since it's no longer present with using 7zz
.
https://github.com/electron-userland/electron-builder/actions/runs/10968249159/job/30459502311
Unfortunately (or fortunately?), 7zz
also gets used by the Go dependency app-builder-bin
https://github.com/develar/app-builder/blob/master/pkg/util/env.go#L21
This is causing the failures in the electron-builder CI, for both artifact downloading (binDownloadTest) and for .ico
conversion (winPackagerTest).
I'll need to investigate further, but it seems we have some package interdependencies and my familiarity with Go is nil.
Update: I've gotten the new 7zip binaries in PR https://github.com/develar/7zip-bin/pull/27 tested with app-builder-bin's extract logic https://github.com/develar/app-builder/pull/139
Working on getting the two dependencies running together through electron-builder's CI but running into pnpm install errors trying to pull from a specific pre-release/feature branch
Alright, got a draft PR up with the updated 7zip binaries. https://github.com/electron-userland/electron-builder/pull/8530 Dependency on https://github.com/develar/7zip-bin/pull/27
One of the notable changes in app-builder-bin upstream dependency was the need to add the extract flag -snld
. It's an undocumented flag but there's probably a reason for that. https://sourceforge.net/p/sevenzip/bugs/2436/
It's needed though to be backward compatible with previous 7zip versions and more notably, it seems previous electron-builder-binaries that were created with the older version of 7zip run into the error linked above
I could fix this on Windows 10 with this solution by adding my user to the security policy for creating symbolic links: https://superuser.com/questions/124679/how-do-i-create-a-link-in-windows-7-home-premium-as-a-regular-user/125981#125981
Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege (“Create symbolic links”), which is granted only to administrators by default (but you can change that using security policy).
It means i can not use vscode terminal to run package
command? because it does not have administrator privilege.Right?
For Windows users who still having this problem:
electron-builder-binaries-winCodeSign-2.6.0\winCodeSign
into %LOCALAPPDATA%\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0
.For what it's worth, I only needed to build with admin rights once, afterwards I can build w/o running vscode as admin
I tried to make Windows installer of my app with following command and settings:
build_win.js
But it is failed with following errors:
Even if I changed the target from NSIS to portable, it was also failed with the same error.
The error says "libssl.dylib" or "Cannot create symbolic link", so I believe it was caused that needless apple resources were extracted in Windows, and failed to create symbolic link on Windows FS. Are there any fix for this or any work-around?