Unable to build simple eletron-forge application using yarn / npm, failing on node-gyp
Checklist
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
flatpak-builder version
1.4.2
Flatpak version
1.14.6
How to reproduce
git clone https://github.com/js-dos/flatpak.dos.zone.browser.pc.git
cd flatpak.dos.zone.browser.pc
flatpak-builder build --install-deps-from=flathub --force-clean --user --install dos.zone.Browser.yaml
Expected Behavior
yarn --offline works fine
Actual Behavior
yarn failing trying to connect to node-gyp repository
fatal: unable to access 'https://github.com/electron/node-gyp/': Could not resolve host: github.com
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Log:
Running: echo "$FLATPAK_BUILDER_BUILDDIR"
/run/build/dos-browser
Running: HOME=$PWD yarn config --offline set yarn-offline-mirror $FLATPAK_BUILDER_BUILDDIR/flatpak-node/yarn-mirror
yarn config v1.22.22
success Set "yarn-offline-mirror" to "/run/build/dos-browser/flatpak-node/yarn-mirror".
Done in 0.01s.
Running: yarn --offline
yarn install v1.22.22
[1/4] Resolving packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://github.com/electron/node-gyp
Directory: /run/build/dos-browser
Output:
fatal: unable to access 'https://github.com/electron/node-gyp/': Could not resolve host: github.com
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Additional Information
So, I have a simple Electron Forge app that I am trying to build for Flathub. I created a manifest file as explained in the tutorial project. I also created a generated-sources.json file and configured the offline cache. However, Yarn is still failing on node-gyp, even though the logs show that node-gyp is downloaded. I couldn’t find any related issues, so I am very confused.
Moreover, I tried doing the same with the NPM packager, but the situation didn’t change. NPM is also failing on node-gyp with the following error:
npm i --offline
npm info using [email protected]
npm info using [email protected]
npm http fetch GET https://registry.npmjs.org/npm attempt 1 failed with EAI_AGAIN
npm warn skipping integrity check for git dependency ssh://[email protected]/electron/node-gyp.git
npm error code ENOTCACHED
npm error request to https://codeload.github.com/electron/node-gyp/tar.gz/06b29aafb7708acef8b3669835c8a7857ebc92d2 failed: cache mode is 'only-if-cached' but no cached response is available.
npm error A complete log of this run can be found in: /run/build/dos-browser/flatpak-node/npm-cache/_logs/2025-01-16T12_05_22_736Z-debug-0.log
When I enter a build environment, I can see that requested node-gyp is downloaded. For npm:
flatpak-builder build --install-deps-from=flathub --force-clean --user --install dos.zone.Browser.yaml --build-shell=dos-browser
sh-5.2$ find . -iname "*06b29aafb7708acef8b3669835c8a7857ebc92d2*"
./flatpak-node/git-packages/@electron/node-gyp-06b29aafb7708acef8b3669835c8a7857ebc92d2
For yarn:
sh-5.2$ find . -iname "*06b29aafb7708acef8b3669835c8a7857ebc92d2*"
./flatpak-node/tmp/node-gyp-06b29aafb7708acef8b3669835c8a7857ebc92d2
./flatpak-node/yarn-mirror/node-gyp-06b29aafb7708acef8b3669835c8a7857ebc92d2
I am really don't know what I did wrong.
Here is electron/node-gyp in generated-sources.json
P.S. The manifest is in WIP state, I am only want to pass yarn --offline or npm i --offline step :)
This is not a flatpak builder issue, node is trying to access the network while flatpak builder by default does not allow network access during build.
You can enable network access by passing --share=network under build-args.
build-options:
build-args:
- --share=network