Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

7zip-bin-linux missing when building on Linux #399

Closed
mbeach opened this issue Mar 8, 2018 · 1 comment · Fixed by #400
Closed

7zip-bin-linux missing when building on Linux #399

mbeach opened this issue Mar 8, 2018 · 1 comment · Fixed by #400

Comments

@mbeach
Copy link

mbeach commented Mar 8, 2018

When npm run build-linux is invoked, the build fails, apparently because somewhere deep in the guts of elelctron-forge the 7zip-bin-linux module can't be found.

Expected Behavior

When npm run build-linux is invoked, I expect the build to succeed, and the file out/make/ganache-1.1.0-beta.1-x86_64.AppImage to be built.

Current Behavior

When npm run build-linux is invoked the build fails with the following output:

> ganache@1.1.0-beta.1 build-linux /home/michaelb/git/ganache2
> cd ./node_modules/rabin-bindings && node-gyp rebuild && cd ../../ && npm run make

make: Entering directory '/home/michaelb/git/ganache2/node_modules/rabin-bindings/build'
  CXX(target) Release/obj.target/rabin-bindings/bindings.o
  CXX(target) Release/obj.target/rabin-bindings/src/rabin.o
  CXX(target) Release/obj.target/rabin-bindings/src/rabin_wrap.o
  SOLINK_MODULE(target) Release/obj.target/rabin-bindings.node
  COPY Release/rabin-bindings.node
make: Leaving directory '/home/michaelb/git/ganache2/node_modules/rabin-bindings/build'

> ganache@1.1.0-beta.1 make /home/michaelb/git/ganache2
> electron-forge make

✔ Checking your system
✔ Resolving Forge Config
We need to package your application before we can make it
✔ Preparing to Package Application for arch: x64
✔ Compiling Application
✔ Preparing native dependencies: 3 / 4
✔ Packaging Application
Making for the following targets:
⠋ Making for target: appimage - On platform: linux - For arch: x64  • electron-builder version=19.52.1
⠙ Making for target: appimage - On platform: linux - For arch: x64  • loaded configuration file=package.json ("build" field)
  • 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`
⠸ Making for target: appimage - On platform: linux - For arch: x64  • writing effective config file=out/make/electron-builder.yaml
  • building        target=AppImage arch=x64 file=out/make/ganache-1.1.0-beta.1-x86_64.AppImage
⠼ Making for target: appimage - On platform: linux - For arch: x64  • downloading     path=/home/michaelb/.cache/electron-builder/appimage/appimage-9.0.3 url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-9.0.3/appimage-9.0.3.7z
✖ Making for target: appimage - On platform: linux - For arch: x64

An unhandled error has occurred inside Forge:
An error occured while making for target: appimage
Cannot find module '7zip-bin-linux'
Error: Cannot find module '7zip-bin-linux'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/michaelb/git/ganache2/node_modules/7zip-bin/index.js:15:67)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at _load_zipBin (/home/michaelb/git/ganache2/node_modules/builder-util/out/binDownload.js:87:22)
    at /home/michaelb/git/ganache2/node_modules/builder-util/src/binDownload.ts:89:3
From previous event:
    at doGetBin (/home/michaelb/git/ganache2/node_modules/builder-util/out/binDownload.js:74:21)
    at getBin (/home/michaelb/git/ganache2/node_modules/builder-util/src/binDownload.ts:30:13)
    at getBinFromGithub (/home/michaelb/git/ganache2/node_modules/builder-util/src/binDownload.ts:20:10)
    at getAppImage (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/targets/tools.ts:14:10)
    at /home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/targets/AppImageTarget.ts:76:29
    at Generator.next (<anonymous>)
    at /home/michaelb/git/ganache2/node_modules/graceful-fs/graceful-fs.js:99:16
    at /home/michaelb/git/ganache2/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
From previous event:
    at AppImageTarget.build (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/out/targets/AppImageTarget.js:186:11)
    at taskManager.addTask.default.map.it (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/platformPackager.ts:121:67)
From previous event:
    at LinuxPackager.packageInDistributableFormat (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/platformPackager.ts:121:23)
    at /home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/platformPackager.ts:116:10
    at Generator.next (<anonymous>)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
From previous event:
    at LinuxPackager.pack (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/out/platformPackager.js:195:11)
    at /home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/packager.ts:355:24
    at Generator.next (<anonymous>)
    at xfs.stat (/home/michaelb/git/ganache2/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16)
    at /home/michaelb/git/ganache2/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:153:5)
From previous event:
    at Packager.doBuild (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/out/packager.js:419:11)
    at /home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/packager.ts:299:52
    at Generator.next (<anonymous>)
    at /home/michaelb/git/ganache2/node_modules/graceful-fs/graceful-fs.js:99:16
    at /home/michaelb/git/ganache2/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
From previous event:
    at Packager._build (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/out/packager.js:363:11)
    at /home/michaelb/git/ganache2/node_modules/electron-builder-lib/src/packager.ts:261:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
From previous event:
    at Packager.build (/home/michaelb/git/ganache2/node_modules/electron-builder-lib/out/packager.js:319:11)
    at /home/michaelb/git/ganache2/node_modules/electron-builder/src/builder.ts:310:40
    at Generator.next (<anonymous>)
From previous event:
    at _build (/home/michaelb/git/ganache2/node_modules/electron-builder/out/builder.js:61:21)
    at build (/home/michaelb/git/ganache2/node_modules/electron-builder/src/builder.ts:280:10)
    at buildForge (/home/michaelb/git/ganache2/node_modules/electron-builder/src/forge/forge-maker.ts:10:10)
    at exports.default (/home/michaelb/git/ganache2/node_modules/electron-forge-maker-appimage/main.js:12:10)
    at /home/michaelb/git/ganache2/node_modules/electron-forge/dist/api/api/make.js:144:35
    at Generator.next (<anonymous>)
    at _promise2.default (/home/michaelb/git/ganache2/node_modules/electron-forge/dist/util/util/ora-handler.js:17:5)
    at new Promise (<anonymous>)
    at new F (/home/michaelb/git/ganache2/node_modules/babel-runtime/node_modules/core-js/library/modules/_export.js:35:28)
    at asyncOra (/home/michaelb/git/ganache2/node_modules/electron-forge/dist/util/util/ora-handler.js:16:10)
    at /home/michaelb/git/ganache2/node_modules/electron-forge/dist/api/api/make.js:142:13
    at Generator.next (<anonymous>)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ganache@1.1.0-beta.1 make: `electron-forge make`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ganache@1.1.0-beta.1 make script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/michaelb/.npm/_logs/2018-03-07T21_44_09_637Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ganache@1.1.0-beta.1 build-linux: `cd ./node_modules/rabin-bindings && node-gyp rebuild && cd ../../ && npm run make`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ganache@1.1.0-beta.1 build-linux script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/michaelb/.npm/_logs/2018-03-07T21_44_09_661Z-debug.log

Steps to Reproduce

  1. Clone the git repository.
  2. npm install
  3. npm run build-linux

Possible Solution

When I looked in node_modules I could see 7zip-bin, but not 7zip-bin-linux. When I looked in package.json I couldn't see either listed, so figured it must be a transitive dependency. When I looked in package-lock.json I could see 7zip-bin and 7zip-bin-mac, but no 7zip-bin-linux or 7zip-bin-win.

My working theory was that npm was only installing what was in package-lock.json, but that file had been build by npm running on a Mac, so only the Mac-flavoured optional dependencies were specified in the file. Some digging turned up npm/npm#19054, which confirmed that prior to version 5.6.0 npm would only put the optional dependencies it could actually install into package-lock.json.

Since I was running a newer npm (version 5.7.1) all that I had to do to fix the problem was rebuild the package-lock.json file by running npm install --package-lock-only. This added all of the optional dependencies of 7zip-bin to package-lock.json, regardless of whether they could be installed on the current OS or not. I will submit a pull request for this fix shortly.

I found the problem could also be made to disappear if I did npm install 7zip-bin (this is more of a hack than a proper solution), as that would force installation of 7zip-bin-linux. Perplexingly, the problem would remain disappeared even if I reverted the changes to package.json and package-lock.json, removed node_modules and then then re-ran npm-install and npm run build-linux. After dismissing the possibility that I was going mad, I discovered that electron-builder maintains a cache directory at ~/.cache/electron-builder/appimage where it stores various 7zip archive files and their extracted contents. As long as this cache remains intact, there is no need to actually use 7zip-bin (and hence no need for 7zip-bin-linux), and so the unsatisfied dependency goes unremarked.

Context

Just trying to build the Linux AppImage file from the git repo.

Your Environment

  • Ganache release v1.1.0-beta.1
  • node v8.10.0
  • npm v5.7.1
  • Linux Mint 18.2 Sonya
mbeach pushed a commit to mbeach/ganache that referenced this issue Mar 8, 2018
Add OS-specific optional dependecies of 7zip-bin to package-lock.json.
These entries were created using "npm install --package-lock-only".
This fixes trufflesuite#399.
@benjamincburns
Copy link
Contributor

Thanks for the PR, @mbeach!

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

Successfully merging a pull request may close this issue.

2 participants