electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

Build hangs when rebuilding native when using npx only

Open mifi opened this issue 3 years ago • 15 comments

  • Electron-Builder Version: 22.13.1
  • Node Version: 16.13.0
  • Electron Version: 8.5.5
  • Electron Type (current, beta, nightly): current
  • Target: darwin
npx electron-builder --mac

  • electron-builder  version=22.14.6 os=20.6.0
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  • writing effective config  file=dist/builder-effective-config.yaml
  • rebuilding native dependencies  [email protected] platform=darwin arch=x64
  • install prebuilt binary  name=drivelist version=9.2.4 platform=darwin arch=x64 napi=
  • build native dependency from sources  name=drivelist
                                          version=9.2.4
                                          platform=darwin
                                          arch=x64
                                          napi=
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.6
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /Users/mifi/.npm/_prebuilds/fee87d-drivelist-v9.2.4-electron-v76-darwin-x64.tar.gz
    prebuild-install http request GET https://github.com/balena-io-modules/drivelist/releases/download/v9.2.4/drivelist-v9.2.4-electron-v76-darwin-x64.tar.gz
    prebuild-install http 404 https://github.com/balena-io-modules/drivelist/releases/download/v9.2.4/drivelist-v9.2.4-electron-v76-darwin-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=8.5.5 runtime=electron arch=x64 libc= platform=darwin)

...then the command hangs and never returns.

When restarting the build with DEBUG we can see this printed:

  • execute command  command=/node-v16.13.0-darwin-x64/bin/node /node-v16.13.0-darwin-x64/lib/node_modules/npm/bin/npx-cli.js rebuild --verbose [email protected]
                     workingDirectory=
  ⨯ cannot execute  cause=exit status 1
                    out=You forgot to tell me what to run when the files changes!

                    command=/node-v16.13.0-darwin-x64/bin/node /node-v16.13.0-darwin-x64/lib/node_modules/npm/bin/npx-cli.js rebuild --verbose [email protected]
                    workingDir=
  • exited          command=app-builder_amd64 code=2 pid=62703

It's trying to run npx-cli.js of the module rebuild which I think is not what is intented. So something seems to be wrong with the code trying to run npm.

Instead running this command (without npx) yields a successful result:

./node_modules/electron-builder --mac
...
  • execute command  command=npm rebuild --verbose [email protected] workingDirectory=
  • command executed  executable=npm
                      out=rebuilt dependencies successfully

mifi avatar Nov 11 '21 14:11 mifi

You can also try npm exec. electron-builder detects the package manager (yarn, npm) and uses it. Instead, npx is detected and IIRC native rebuilds end up being executed incorrectly

mmaietta avatar Nov 11 '21 16:11 mmaietta

npm exec works! But in electron-builder npx is mentioned, so maybe this line should be changed to instead npm exec: https://github.com/electron-userland/electron-builder/blob/93bf3597f689466fd5b5a5ff37eb633ffa3c1063/docs/cli.md?plain=1#L44

anyways it would be nice if:

  1. electron-builder doesn't hang when that command fails, but instead spits out the actual error
  2. npx also works because I'm guessing many people are using npx still

this issue may be related to yarn workspaces btw (I get it when running inside a workspace subdir)

mifi avatar Nov 13 '21 13:11 mifi

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Apr 16 '22 16:04 stale[bot]

Still an issue with npx

mifi avatar Apr 16 '22 17:04 mifi

Just hit this today.

kyrofa avatar Apr 21 '22 20:04 kyrofa

I have this issue too since upgrading from npm 14 to 16

Simon-Laux avatar Apr 30 '22 12:04 Simon-Laux

Just encountered this today for myself. Updated node vom v12 to v16 & npm dependencies from an old project from like 2019 or so and npx electron-builder would hang for me after checking for prebuilds on this command:

/usr/bin/node /usr/lib/node_modules/npm/bin/npx-cli.js rebuild --verbose <package1> <package2> <package3> workingDirectory=

Calling npm exec electron-builder wont hang here and will result in a successful build.


electron-builder: v23.0.3 node: v16.15.1 npm: v8.11.0

RicoBrase avatar Jun 20 '22 13:06 RicoBrase

"npm exec electron-builder" doesn't work on Windows and tries to open electron-builder.js in a file editor

amoscatelli avatar Aug 03 '22 12:08 amoscatelli

"npm exec electron-builder" doesn't work on Windows

npm exec --package=electron-builder -- electron-builder same?

vladimiry avatar Aug 03 '22 12:08 vladimiry

yes, that's the same, doens't change a thing

amoscatelli avatar Aug 03 '22 12:08 amoscatelli

I don't run Windows, but I remember it worker well on GH CI Windows image/env.

yes, that's the same, doens't change a thing

npm -v (If I remember it right, exec got supported since npm v7)?

vladimiry avatar Aug 03 '22 12:08 vladimiry

I don't run Windows, but I remember it worker well on GH CI Windows image/env.

yes, that's the same, doens't change a thing

npm -v (If I remember it right, exec got supported since npm v7)?

8.15.0

I confirm running "npm exec --package=electron-builder -- electron-builder" opens electron-builder.js in my notepad++

amoscatelli avatar Aug 03 '22 12:08 amoscatelli

On windows I resorted to "./node-modules/.bin/electron-builder" to build using local installation

amoscatelli avatar Aug 03 '22 12:08 amoscatelli

Just encountered this today for myself. Updated node vom v12 to v16 & npm dependencies from an old project from like 2019 or so and npx electron-builder would hang for me after checking for prebuilds on this command:

/usr/bin/node /usr/lib/node_modules/npm/bin/npx-cli.js rebuild --verbose <package1> <package2> <package3> workingDirectory=

Calling npm exec electron-builder wont hang here and will result in a successful build.

electron-builder: v23.0.3 node: v16.15.1 npm: v8.11.0

I should add that I was trying to build on a Raspberry Pi running a linux distribution, since I needed a 32-bit ARM (armv7l) AppImage package.

RicoBrase avatar Aug 07 '22 16:08 RicoBrase

I confirm running "npm exec --package=electron-builder -- electron-builder" opens electron-builder.js in my notepad++

This is a different issue and is expected behavior, not related to electron-builder. Node seems to search the current directory for any executable script named electron-builder, so it pulls up electron-builder.js in notebad. Simple solution, rename your file electron-builder-config.js and pass it in with --config arg

mmaietta avatar Aug 16 '22 16:08 mmaietta

node14 is ok but node16 encounters this error, while execing npx electron-builder xxx

so I use node_modules/.bin/electron-builder instead of npx, this worked for me electron-builder: 8.5.0

qishibo avatar Oct 15 '22 09:10 qishibo

Same here: This hangs at "install prebuilt binary" and needs Ctrl-C:

$ npx electron-builder build --win portable
  • electron-builder  version=23.6.0 os=10.0.19043
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=dist\builder-effective-config.yaml
  • "electron-squirrel-startup" dependency is not required for NSIS
  • rebuilding native dependencies  dependencies=@serialport/[email protected], [email protected] platform=win32 arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.6.2 platform=win32 arch=x64 napi=
  • cancelled by SIGINT
  ⨯ D:\ProgettiLavoro\HURV\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
3221225786  failedTask=build stackTrace=Error: D:\ProgettiLavoro\HURV\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
3221225786
    at ChildProcess.<anonymous> (D:\ProgettiLavoro\HURV\node_modules\builder-util\src\util.ts:250:14)
    at Object.onceWrapper (node:events:642:26)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.cp.emit (D:\ProgettiLavoro\HURV\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

Instead this works fine:

$ ./node_modules/.bin/electron-builder build --win portable
  • electron-builder  version=23.6.0 os=10.0.19043
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=dist\builder-effective-config.yaml
  • "electron-squirrel-startup" dependency is not required for NSIS
  • rebuilding native dependencies  dependencies=@serialport/[email protected], [email protected] platform=win32 arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.6.2 platform=win32 arch=x64 napi=
  • packaging       platform=win32 arch=x64 electron=17.4.11 appOutDir=dist\win-unpacked
  • default Electron icon is used  reason=application icon is not set
  • building        target=portable file=dist\hli-ram-view 1.0.0.exe archs=x64

BTW I'm on Windows 10 from VSCode terminal

olimexsmart avatar Oct 21 '22 08:10 olimexsmart

just got the thing too, stuck after using npx electron-builder, using npm exec gives me error, i had to install electron builder globally and then it works

shahriar0247 avatar Oct 25 '22 17:10 shahriar0247

Potentially related: https://github.com/electron-userland/electron-builder/issues/7090

juliangruber avatar Feb 06 '23 16:02 juliangruber

I have same issue if i use npm exec i have error on rebuild native dependecies. on node v14 work good after migrate on v16 i have error.

sergeushenecz avatar Apr 03 '23 20:04 sergeushenecz

Same issue here with better-sqlite3 package and any version of node above 14. Hangs indefinitely on install prebuilt binary (waited 4 hours then gave up). Only an issue in github action, works fine locally.

image

Jazcash avatar Apr 19 '23 00:04 Jazcash

Try npm exec -- electron-builder instead of npx electron-builder

juliangruber avatar Apr 19 '23 20:04 juliangruber

This has started happening to me in Github Actions after upgrade to latest on all packages.

electron-builder: v23.6.0 node: v18.3.0 npm: v8.11.0

 execute command  command='C:\hostedtoolcache\windows\node\18.3.0\x64\node.exe' 'C:\hostedtoolcache\windows\node\18.3.0\x64\node_modules\npm\bin\npx-cli.js' rebuild --verbose [email protected] [email protected]

Source: https://github.com/typerefinery-ai/typerefinery/actions/runs/4979950195/jobs/8912352154

Trying to install these packages globally.

wildone avatar May 15 '23 16:05 wildone

Oh gosh. I just tripped across this issue after being frustrated by this issue for days without knowing what I was doing wrong. I'd love to see a fix!

rotu avatar Aug 18 '23 20:08 rotu

I'm hitting this issue with GitHub Actions (using https://github.com/samuelmeuli/action-electron-builder). Locally, npm run dist (which is electron-builder) and npm exec electron-builder work fine, but npx electron-builder does not.

j0hnm4r5 avatar Sep 02 '23 21:09 j0hnm4r5

Have you tried npm exec -- electron-builder instead of npx electron-builder?

juliangruber avatar Sep 03 '23 09:09 juliangruber

I think the root cause is https://github.com/npm/cli/issues/6662 via https://github.com/develar/app-builder/blob/4e2aa6a12e2bc3d31ec0d01d661fb3a4d65248ff/pkg/node-modules/rebuild.go#L361-L366

rotu avatar Sep 03 '23 17:09 rotu

Root cause https://github.com/npm/cli/issues/6662 is now fixed in [email protected]!

rotu avatar Sep 09 '23 04:09 rotu