forge icon indicating copy to clipboard operation
forge copied to clipboard

Linux distros should only run makers for their target platfrm by default

Open DrHyde opened this issue 1 year ago • 3 comments

Pre-flight checklist

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project uses.
  • [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.6.0

Electron version

v33.2.1

Operating system

Devuan GNU/Linux 5 (daedalus), x64

Last known working Electron Forge version

No response

Expected behavior

I tried to build my code on Devuan. The exact same code builds just fine on a Mac. npm run make should produce a working binary in the out/ directory.

Actual behavior

$ npm run make

> [email protected] make
> electron-forge make

✔ Checking your system
✔ Loading configuration
✖ Resolving make targets
  › Cannot make for rpm, the following external binaries need to be installed: rpmbuild
◼ Running package command
◼ Running preMake hook
◼ Making distributables
◼ Running postMake hook

An unhandled rejection has occurred inside Forge:
Error: Cannot make for rpm, the following external binaries need to be installed: rpmbuild
at MakerRpm.ensureExternalBinariesExist (/home/david/unicode-search/node_modules/@electron-forge/maker-base/dist/Maker.js:107:19)
    at /home/david/unicode-search/node_modules/@electron-forge/core/dist/api/make.js:119:27
    at async _Task.taskFn (/home/david/unicode-search/node_modules/@electron-forge/tracer/dist/index.js:58:20)
    at async _Task.run (/home/david/unicode-search/node_modules/listr2/dist/index.cjs:2063:11)

Steps to reproduce

To reproduce:

  • clone my repo, on a Devuan machine;
  • make deps (to install Electron etc)
  • make build

Additional information

A very similar error was reported previously in #1262 and "fixed" by improving the error message to make it clear that Electron is trying to erroneously run Redhat-specific tools on a non-Redhat machine. Making the error message more clear is obviously not in fact a fix. A fix would be a code change to make it stop running Redhat stuff on any platform except Redhat, unless specifically asked to do so, just like you would only run Mac-specific tools on a Mac, and Windows-specific tools on Windows.

DrHyde avatar Nov 30 '24 15:11 DrHyde

As a work-around, users who aren't on Redhat can apt-get install rpm but this is obviously far from ideal.

DrHyde avatar Nov 30 '24 15:11 DrHyde

Reading through the source code (thanks for linking the previous PR), it seems like the requirement on rpmbuild is only present when using maker-rpm.

https://github.com/electron/forge/blob/cb656908606bf803866738e9b970303bd9fe206b/packages/maker/rpm/src/MakerRpm.ts#L22

It seems like maker-rpm and maker-deb are both configured in your Forge config:

https://github.com/DrHyde/unicode-search/blob/34d1fa89ff35a8edae94d1633352a26615c7e7d4/forge.config.js#L22-L25

So the ask here would be to be able to configure your makers to only run maker-rpm when rpmbuild is detected rather than erroring out?

I feel like the opposite problem (if it skips it silently and you're trying to build for rpm as well) would also be annoying and harder to debug.

I wonder if this would be a valid workaround for this case, since your Forge config is a JavaScript file:

// or some other way of detecting if you're running on RHEL
const isRHEL = fs.existsSync('/etc/redhat-release');

const makers = [{...}];

if (isRHEL) makers.push({name: '@electron-forge/maker-rpm', config: {}});

erickzhao avatar Jan 31 '25 00:01 erickzhao

Ah-ha! Yes, that work-around does exactly what I need, thanks!

DrHyde avatar Feb 22 '25 22:02 DrHyde