Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot execute pnpm.cjs: %1 is not a valid Win32 application. #63

Closed
Alduino opened this issue Aug 2, 2021 · 1 comment · Fixed by #66
Closed

cannot execute pnpm.cjs: %1 is not a valid Win32 application. #63

Alduino opened this issue Aug 2, 2021 · 1 comment · Fixed by #66

Comments

@Alduino
Copy link
Contributor

Alduino commented Aug 2, 2021

app-builder-bin version: 3.5.13
node version: 14.17.3

I'm trying to build my Electron app using electron-builder (v22.11.7), but it is failing with the error in the title. It appears the issue occurs in this library, which is why I am posting it here.

The full logs are available at the Github action but I've copied what seems relevant at the end of the issue.

My guess is that the issue is happening in https://github.com/develar/app-builder/blob/master/pkg/node-modules/rebuild.go#L361.

I've made a minimum reproduction of it at https://github.com/Alduino/app-builder-navw32a-repro. The logs are in its gh actions. The issue occurs both using workspaces and without, and with two different libraries ([email protected], [email protected]).

Relevant logs (from the reproduction as they are shorter)
> [email protected] postinstall D:\a\app-builder-navw32a-repro\app-builder-navw32a-repro
> electron-builder install-app-deps

  • electron-builder  version=22.11.7
  • spawning        command=D:\a\app-builder-navw32a-repro\app-builder-navw32a-repro\node_modules\.pnpm\[email protected]\node_modules\app-builder-bin\win\x64\app-builder.exe node-dep-tree --dir D:\a\app-builder-navw32a-repro\app-builder-navw32a-repro
  • exited          command=app-builder.exe code=0 pid=4212 out=[{"dir":"D:\\a\\app-builder-navw32a-repro\\app-builder-navw32a-repro\\node_modules","deps":[{"name":"register-scheme","version":"0.0.2"}]}]
  • spawning        command=D:\a\app-builder-navw32a-repro\app-builder-navw32a-repro\node_modules\.pnpm\[email protected]\node_modules\app-builder-bin\win\x64\app-builder.exe rebuild-node-modules cwd=D:\a\app-builder-navw32a-repro\app-builder-navw32a-repro
  • map async       taskCount=1
  • map async       taskCount=1
  • rebuilding native dependencies  [email protected] platform=win32 arch=x64
  • map async       taskCount=1
  • execute command  command='C:\Users\runneradmin\setup-pnpm\node_modules\.pnpm\[email protected]\node_modules\pnpm\bin\pnpm.cjs' rebuild --verbose [email protected] workingDirectory=
  ⨯ cannot execute  cause=fork/exec C:\Users\runneradmin\setup-pnpm\node_modules\.pnpm\[email protected]\node_modules\pnpm\bin\pnpm.cjs: %1 is not a valid Win32 application.
                    command='C:\Users\runneradmin\setup-pnpm\node_modules\.pnpm\[email protected]\node_modules\pnpm\bin\pnpm.cjs' rebuild --verbose [email protected]
                    workingDir=
  • exited          command=app-builder.exe code=2 pid=7004
 ERROR  Command failed with exit code 1.
@Alduino
Copy link
Contributor Author

Alduino commented Sep 7, 2021

From some further inspection, it seems that the issue is because readHashBang in the file I referenced only checks the first part of the hash bang (before a space). Because pnpm uses the /usr/bin/env node form of hashbang, app-builder isn't detecting that it should be run using node.

There are a couple ways this could be worked around - pnpm uses the .cjs file extension, so that could be added as one that is recognised as a js file. Or, the hashbang detection could be improved to support /usr/bin/env. I'll make a PR tomorrow to do the latter (I've got to sleep now) - I've tested it in the reproduction repo I made, and it seems to work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant