electron-builder: Failed to create dylib symbolic link on Windows

  • Electron-Builder Version: 24.13.3
  • Node Version: v18.16.1
  • Electron Version: 29.1.5
  • Electron Type (current, beta, nightly): current
  • Target: Both NSIS and portable on Windows (Both results are same)

I tried to make Windows installer of my app with following command and settings:

electron-builder --win --x64 --config ./build_win.js

build_win.js

const config = {
  "appId": "jp.maplat.editor",
  "directories": {
    "output": "dist"
  },
  "files": [
    "assets/win",
    "backend",
    "css",
    "frontend/api",
    "frontend/dist",
    "frontend/fonts",
    "html",
    "img",
    "locales",
    "package.json",
    "package-lock.json",
    "tms_list.json"
  ],
  "win": {
    "icon": "assets/win/icon_win.ico",
    "target": "portable"
  },
  "nsis":{
    "oneClick": false,
    "allowToChangeInstallationDirectory": true
  }
};

module.exports = config;

But it is failed with following errors:

  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z size=5.6 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z duration=1.104s
  ⨯ cannot execute  cause=exit status 2
                    out=
    7-Zip (a) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26

    Scanning the drive for archives:
    1 file, 5635384 bytes (5504 KiB)

    Extracting archive: C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign\618674575.7z
    --
    Path = C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign\618674575.7z
    Type = 7z
    Physical Size = 5635384
    Headers Size = 1492
    Method = LZMA2:24m LZMA:20 BCJ2
    Solid = +
    Blocks = 2


    Sub items Errors: 2

    Archives with Errors: 1

    Sub items Errors: 2

                    errorOut=ERROR: Cannot create symbolic link : �N���C�A���g�͗v�����ꂽ�������ۗL���Ă��܂����B : C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeS Sign\618674575\darwin\10.12\lib\libcrypto.dylib
    ERROR: Cannot create symbolic link : �N���C�A���g�͗v�����ꂽ�������ۗL���Ă��܂����B : C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign\618674575\darwin\10.1 12\lib\libssl.dylib

                    command='C:\Users\kochi\github\MaplatEditor\node_modules\7zip-bin\win\x64\7za.exe' x -bd 'C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign\618674575.7z' '-oC:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign\618674575'
                    workingDir=C:\Users\kochi\AppData\Local\electron-builder\Cache\winCodeSign

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?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 25
  • Comments: 41 (3 by maintainers)

Commits related to this issue

Most upvoted comments

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: image

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:

  • You don’t need admin rights
  • You can use the latest version of electron-builder
  • You need to do this only once as preparation step, also easy to realize in a CI environment

Con

  • You have to do it as long as this issue is not fixed.

FYI, it seems like it’s an issue with the 7zip upgrade under the hood. Workaround: downgrade to electron-builder@24.6.3.

Update here. Investigating into changing the release process of electron-builder-binaries such that the winCodeSign assets are split up per platform, as opposed to the current setup where linux/mac/windows are all in the same zip archive. This should bypass the issue with symlinks being present in the archive being extracted when building on Windows.

Looks like the symlinks are within darwin/10.12/*, but I’m not even sure we need to maintain those in the archive, as 10.12 EOL was November 30, 2019 lol. Might be worth just removing those tbh

If you are using an editor like VS Code, run it with administrator privileges.

This is not a good idea.

This error is happening in our CI where running as administrator is not allowed. Is there a workaround for running as an unprivileged user?

Prepping release of updated win-codesign package in https://github.com/electron-userland/electron-builder-binaries/pull/72

It creates 3 separate artifacts, osslsigncode.7z, rcedit.7z and windows-toolkit.7z w/ windows-10 dir for x64, x86, and now also arm64) , separating out packages by purpose and more notably, no longer containing any symlinks.

Need to still test it in electron-builder though

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).

This problem is due to privilege. The solution is simple, just open your project folder in CMD or PowerShell with ADMINISTRATOR privileges.

Ex: image

Thanks it worked for me. I have tried many ways done its working fine

For Windows users who still having this problem:

  1. download zip from url below:
  1. unzip it. It won’t require any Admin privilege.
  2. copy files and folders under electron-builder-binaries-winCodeSign-2.6.0\winCodeSign into %LOCALAPPDATA%\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0.
  3. electron-builder will start working.

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 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

image

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 in C:\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.

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!

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.

Turn on Developer Mode helps me bypass the issue

Win11 Settings > System > For developers > Developer Mode

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).

  1. Right click on Start→Run and launch secpol.msc.
  2. Open Security Settings → Local Policies → User Rights Assignment and select Create symbolic links (that represents SeCreateSymbolicLinkPrivilege).
  3. Double-click on the item and add yourself (or the whole Users group) to the list.

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

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.