[Bug] Linux: electron-builder --linux will execute "install --production" instead of "npm install --production"
See original GitHub issue-
Electron-Builder Version: (latest, installed today)
-
Node Version: 16.9.1
-
Electron Version: 15.3.0 (latest stable)
-
Target: linux (doesn’t matter which target, all targets are affected)
How to reproduce:
- Use
npx electron-builder --linux
on ArchLinux, inside a sandbox whereelectron-builder
was installed before, and the electron-builder.json file is used, valid, and works after a manual execution ofnpm install
inside the sandboxed folder.
Where’s the Bug?:
It seems to execute the native install
binary (from coreutils
) with the --production
parameter, which the error message install: unrecognized option '--production'
implies as it’s the stderr
output of the install binary.
This seems to be caused by the yarn.ts file which relies on environment variables to be set for the npm
binary path.
I think that the checks afterwards are broken when there’s no yarn installed and the environment variables aren’t set, as it will lead to the following variables (note that npx
was used to execute electron-builder
as it wasn’t installed globally).
// inserted a console.log at line 101 in the yarn.js file, which is a tsc generated file so it's hard to debug
execPath = '/usr/bin/node';
execArgs = [
'/usr/lib/node_modules/npm/bin/npx-cli.js',
'install',
'--production',
'--prefer-offline'
];
Obviously, these parameters are wrong and should not be the case. I’m not sure what all the yarn berry unshift()
code is about and why there have to be so many checks when it seems that this is a platform-specific method that should’ve been isolated per-platform as the environment variables are different on each platform.
Anyways, this is the bug, and it’s currently like this for Linux users. I would’ve created a pull request, but I don’t know what to do because the tests don’t seem to cover this, and I don’t have yarn installed and neither other operating systems at hand to test out all the expected branches for all scenarios here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
This shouldn’t be closed. It’s still an issue
I think the
npx
is being utilized and causing it to runnpx rebuild
instead ofnpm rebuild
. Can you trynpm exec electron-builder --linux
?