electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.61k stars 1.74k forks source link

!include: could not open file: build failed in github action with app-builder-lib #8175

Closed Soltus closed 2 months ago

Soltus commented 5 months ago
Error output:
!include: could not open file: "...\node_modules\.pnpm\app-builder-lib@25.0.0-alpha.6_dmg-builder@25.0.0-alpha.6_electron-builder-squirrel-windows@2_jamshtybgehbmy77zbhfnvoaye\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
Error in script "<stdin>" on line 1 -- aborting creation process
  failedTask=build stackTrace=Error: C:\Users\runneradmin\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Soltus commented 5 months ago

if i use "electron-builder": "24.9.1", LGTM

drahmedshaheen commented 5 months ago

downgrading to "electron-builder": "^23.6.0" worked for me

88250 commented 5 months ago

Same issue:

⨯ C:\Users\runneradmin\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=org.b3log.siyuan"
Command line defined: "APP_GUID=c1e77cb7-68e1-5adb-ab[29](https://github.com/siyuan-note/siyuan/actions/runs/8876860253/job/24369309604#step:19:30)-ecf7379a9944"
Command line defined: "UNINSTALL_APP_KEY=c1e77cb7-68e1-5adb-ab29-ecf7379a9944"
Command line defined: "PRODUCT_NAME=SiYuan"
Command line defined: "PRODUCT_FILENAME=SiYuan"
Command line defined: "APP_FILENAME=SiYuan"
Command line defined: "APP_DESCRIPTION=Refactor your thinking"
Command line defined: "VERSION=3.0.11"
Command line defined: "PROJECT_DIR=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app"
Command line defined: "BUILD_RESOURCES_DIR=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\build"
Command line defined: "APP_PACKAGE_NAME=SiYuan"
Command line defined: "MUI_ICON=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\src\assets\icon.ico"
Command line defined: "MUI_UNICON=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\src\assets\icon.ico"
Command line defined: "APP_64=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\build\SiYuan-3.0.11-x64.nsis.7z"
Command line defined: "APP_64_NAME=SiYuan-3.0.11-x64.nsis.7z"
Command line defined: "APP_64_HASH=3D25DC1177228CB38DB6F6B7A6CA9EDD518574A3894C0E83285642644853E6835E16187458ACF6DC3B4AE55753B50C0D0C79BF788497E52D8F1F9B6A226F3A17"
Command line defined: "APP_64_UNPACKED_SIZE=400874"
Command line defined: "COMPANY_NAME=Yunnan Liandi Technology Co., Ltd."
Command line defined: "MUI_WELCOMEFINISHPAGE_BITMAP=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\nsis\installerSidebar.bmp"
Command line defined: "MUI_UNWELCOMEFINISHPAGE_BITMAP=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\nsis\uninstallerSidebar.bmp"
Command line defined: "ESTIMATED_SIZE=398610"
Command line defined: "COMPRESS=auto"
Command line defined: "BUILD_UNINSTALLER"
Command line defined: "UNINSTALLER_OUT_FILE=D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\build\__uninstaller-nsis-SiYuan.exe"
Processing config: C:\Users\runneradmin\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\nsisconf.nsh
Processing script file: "<stdin>" (UTF8)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Error output:
!include: could not open file: "D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3_dmg-bui_lrspnoputfiosacwyigcypdbdi\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
Error in script "<stdin>" on line 1 -- aborting creation process
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        at ChildProcess.<anonymous> (D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\node_modules\.pnpm\builder-util@24.13.1\node_modules\builder-util\src\util.ts:252:14)
    at Object.onceWrapper (node:events:633:26)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess.cp.emit (D:\a\siyuan\siyuan\go\src\github.com\siyuan-note\siyuan\app\node_modules\.pnpm\cross-spawn@7.0.3\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1105:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:[30](https://github.com/siyuan-note/siyuan/actions/runs/8876860253/job/24369309604#step:19:31)5:5)
 ELIFECYCLE  Command failed with exit code 1.
Soltus commented 5 months ago

升级 electron 30 后 electron-builder 需要降级到 24.9.1 ,目前只能二选一等上游解决这个问题,这个冲突只影响 action 本地构建没事。我建议降级 electron-builder @88250

88250 commented 5 months ago

@Soltus 多谢指点,我马上试试!

Soltus commented 5 months ago

@88250 工作流似乎没有必要现在就升级到 node 22,大部分 action 都是基于 node 20 的,还是保持一致比较好

Soltus commented 5 months ago

pnpm 9.0.6 是没问题的 https://github.com/Hi-Windom/Sillot/actions/runs/8868983094/job/24349164505 目前看起来唯一的不同就是 nod 22 了

88250 commented 5 months ago

@Soltus 多谢了,降级 Node 20 和 Builder 24.9.1 后 Action 构建成功了。

goosewobbler commented 5 months ago

I'm getting this with 24.13.1 on Windows but 24.13.0 works fine. Using pnpm and Electron v29. I wonder if this is caused by https://github.com/electron-userland/electron-builder/pull/8052...

EDIT: We're experiencing timeouts of our electron-builder E2Es on Windows when using Electron 30, which may be related. Sticking to Electron 29 and electron-builder@24.13.0 for now.

oliverschwendener commented 4 months ago

I have the same issue, using

Downgrading electron-builder to 24.9.1 solved the issue as a workaround for me.

XCompWiz commented 3 months ago

Downgrading to 24.13.0 seems to work for us. 24.13.1 is the first version to not work in our case.

Seems to be related to long file paths in Windows. If the working directory is moved closer to root it works with 24.13.3 (shorten the file paths). This is particularly relevant for Windows CI, as runners tend to force a long initial file path before the repo directory, and then absolute paths from there become very long.

We are also using pnpm, so this is potentially an interaction with the tree structure pnpm uses for node_modules.

AiHaibara commented 2 months ago

Downgrading to 24.13.0 seems to work for us. 24.13.1 is the first version to not work in our case.

Seems to be related to long file paths in Windows. If the working directory is moved closer to root it works with 24.13.3 (shorten the file paths). This is particularly relevant for Windows CI, as runners tend to force a long initial file path before the repo directory, and then absolute paths from there become very long.

We are also using pnpm, so this is potentially an interaction with the tree structure pnpm uses for node_modules.

it seems this can be a workaround for the issue, but anyone can help to fix this or how to let it allow long file paths in Windows? I set Registry to allow long file paths in Windows in powershell, but it seems not working for this.

mmaietta commented 2 months ago

This seems to be the only PR that I can find that might cause this, but I still don't understand how peerDependencies would cause this. https://github.com/electron-userland/electron-builder/pull/8052 I took a look at the diff between 24.13.0 and 24.13.1 and there are no code-related changes that would impact file paths

I did find these settings for PNPM that may be useful? https://pnpm.io/next/npmrc#virtual-store-dir https://pnpm.io/next/npmrc#virtual-store-dir-max-length

Would someone be willing to try out values for those two .npmrc fields and see if that resolves the issue?

If anyone could create a minimum reproducible repo for this, I'd be happy to take a look at this as I haven't been able to replicate this locally or in this repo's CI flow.

Soltus commented 2 months ago

Yes, a short virtual-store-dir-max-length in .npmrc like 80 is useful. However, this pnpm configuration item was added after the problem occurred

As far as I know, GitHub Actions' Windows-latest already supports long paths by default.

run: |
    Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled'
    Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1

For pnpm workspace, it should be configured in the root .npmrc

The specific configuration of the virtual-store-dir-max-length may depend on the path length of the checkout repository

mmaietta commented 2 months ago

Fair point. Well we could revert the PR and see what happens in 25.0.1. Would love to enable you folks to be able to update your electron-builder versions. What are your thoughts?

Soltus commented 2 months ago

I can test it at any time, although I don't understand how this PR affects it.

AiHaibara commented 2 months ago

This seems to be the only PR that I can find that might cause this, but I still don't understand how peerDependencies would cause this. #8052 I took a look at the diff between 24.13.0 and 24.13.1 and there are no code-related changes that would impact file paths

I did find these settings for PNPM that may be useful? https://pnpm.io/next/npmrc#virtual-store-dir https://pnpm.io/next/npmrc#virtual-store-dir-max-length

Would someone be willing to try out values for those two .npmrc fields and see if that resolves the issue?

If anyone could create a minimum reproducible repo for this, I'd be happy to take a look at this as I haven't been able to replicate this locally or in this repo's CI flow.

this working for me when setting virtual-store-dir-max-length=80 at .npmrc and some notice is need to running pnpm install for it before build, and it's working for 25.0.0 version also when i setting this.

Soltus commented 2 months ago

Yes, node_module needs to be rebuilt after setup, but for github actions every run is a brand new pnpm install

goosewobbler commented 2 months ago

setting virtual-store-dir-max-length=80 seems to work for me (using EB v25.0.0)