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

Electron 12.0.2 + sharp 0.28.1 fails to build (without running npm i -g prebuild-install) #2651

Closed
mceachen opened this issue Apr 5, 2021 · 4 comments

Comments

@mceachen
Copy link
Contributor

mceachen commented Apr 5, 2021

I created an empty project with just electron and sharp. Here's the package.json:

{
  "name": "sharp-electron-test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "postinstall": "rm -rf node_modules/prebuild-install && yarn electron-builder install-app-deps"
  },
  "devDependencies": {
    "electron": "^12.0.2",
    "electron-builder": "^22.10.5"
  },
  "dependencies": {
    "sharp": "0.28.0"
  }
}

This project builds fine:

$ yarn install --force  --no-default-rc
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info dmg-license@1.0.8: The platform "linux" is incompatible with this module.
info "dmg-license@1.0.8" is an optional dependency and failed compatibility check. Excluding it from installation.
info iconv-corefoundation@1.1.5: The platform "linux" is incompatible with this module.
info "iconv-corefoundation@1.1.5" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Rebuilding all packages...
success Saved lockfile.
$ rm -rf node_modules/prebuild-install && yarn electron-builder install-app-deps
yarn run v1.22.10
$ /home/mrm/src/sharp-electron-test/node_modules/.bin/electron-builder install-app-deps
  • electron-builder  version=22.10.5
  • rebuilding native dependencies  dependencies=sharp@0.28.0 platform=linux arch=x64
  • install prebuilt binary  name=sharp version=0.28.0 platform=linux arch=x64
  ⨯ cannot find prebuild-install  
  • rebuilding native dependency  name=sharp version=0.28.0
Done in 11.28s.
Done in 16.16s.

If I change sharp to 0.28.1, yarn install fails:

mrm@speedy:~/src/sharp-electron-test$ rm -rf ~/.electron ~/.cache/electron* ~/.electron-gyp ~/.npm/_libvips ~/AppData/Roaming/npm-cache/_libvips ~/.node-gyp ~/.cache/yarn/*/*sharp* node_modules
mrm@speedy:~/src/sharp-electron-test$ yarn install --force  --no-default-rc
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info dmg-license@1.0.8: The platform "linux" is incompatible with this module.
info "dmg-license@1.0.8" is an optional dependency and failed compatibility check. Excluding it from installation.
info iconv-corefoundation@1.1.5: The platform "linux" is incompatible with this module.
info "iconv-corefoundation@1.1.5" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Rebuilding all packages...
success Saved lockfile.
$ rm -rf node_modules/prebuild-install && yarn electron-builder install-app-deps
yarn run v1.22.10
$ /home/mrm/src/sharp-electron-test/node_modules/.bin/electron-builder install-app-deps
  • electron-builder  version=22.10.5
  • rebuilding native dependencies  dependencies=sharp@0.28.1 platform=linux arch=x64
  • install prebuilt binary  name=sharp version=0.28.1 platform=linux arch=x64
  ⨯ cannot find prebuild-install  
  • rebuilding native dependency  name=sharp version=0.28.1
  ⨯ cannot execute  cause=exit status 1
                    out=$ (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
    sharp: Using existing vendored libvips v8.10.6
    make: Entering directory '/home/mrm/src/sharp-electron-test/node_modules/sharp/build'
      CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
      AR(target) Release/obj.target/../node-addon-api/nothing.a
      COPY Release/nothing.a
      TOUCH Release/obj.target/libvips-cpp.stamp
      CXX(target) Release/obj.target/sharp/src/common.o
    make: Leaving directory '/home/mrm/src/sharp-electron-test/node_modules/sharp/build'
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
                    errorOut=/bin/sh: 1: prebuild-install: not found
    gyp info it worked if it ends with ok
    gyp info using node-gyp@7.1.2
    gyp info using node@14.16.0 | linux | x64
    gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
    gyp http GET https://electronjs.org/headers/v12.0.2/node-v12.0.2-headers.tar.gz
    gyp http 200 https://electronjs.org/headers/v12.0.2/node-v12.0.2-headers.tar.gz
    gyp http GET https://electronjs.org/headers/v12.0.2/SHASUMS256.txt
    gyp http 200 https://electronjs.org/headers/v12.0.2/SHASUMS256.txt
    gyp info spawn /usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/src/sharp-electron-test/node_modules/sharp/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/.electron-gyp/12.0.2/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/home/mrm/.electron-gyp/12.0.2',
    gyp info spawn args   '-Dnode_gyp_dir=/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/home/mrm/.electron-gyp/12.0.2/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/home/mrm/src/sharp-electron-test/node_modules/sharp',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    ../src/common.cc:24:10: fatal error: vips/vips8: No such file or directory
       24 | #include <vips/vips8>
          |          ^~~~~~~~~~~~
    compilation terminated.
    make: *** [sharp.target.mk:145: Release/obj.target/sharp/src/common.o] Error 1
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
    gyp ERR! System Linux 5.8.0-48-generic
    gyp ERR! command "/home/mrm/.nvm/versions/node/v14.16.0/bin/node" "/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /home/mrm/src/sharp-electron-test/node_modules/sharp
    gyp ERR! node -v v14.16.0
    gyp ERR! node-gyp -v v7.1.2
    gyp ERR! not ok 
    error Command failed with exit code 1.
    
                    command=/home/mrm/.nvm/versions/node/v14.16.0/bin/node /home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/home/mrm/src/sharp-electron-test/node_modules/sharp
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the output of running npx envinfo --binaries --system?

$ npx envinfo --binaries --system

  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 6.25 GB / 62.79 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
    npm: 7.7.0 - ~/.nvm/versions/node/v14.16.0/bin/npm
@mceachen
Copy link
Contributor Author

mceachen commented Apr 5, 2021

If I npm i -g prebuild-install, the build passes.

If I add prebuild-install as a devDependency, it's ignored.

@mceachen mceachen changed the title Electron 12.0.2 + sharp 0.28.1 fails to build Electron 12.0.2 + sharp 0.28.1 fails to build (without running npm i -g prebuild-install) Apr 5, 2021
@lovell
Copy link
Owner

lovell commented Apr 6, 2021

sharp v0.28.1 depends on prebuild-install v6.1.1, which is the latest version published to npm.

I notice you've used the --force flag so perhaps there's a conflict with the change in prebuild/prebuild-install#140

@mceachen
Copy link
Contributor Author

mceachen commented Apr 6, 2021

I notice you've used the --force flag so perhaps there's a conflict with the change in prebuild/prebuild-install#140

I just uninstalled the globally-installed prebuild-install, cleaned out node_modules, and just ran yarn install, and got the same error. 😢

npm install failed with the same error as yarn install.

$ npm uninstall -g prebuild-install

removed 58 packages, and audited 1 package in 197ms

found 0 vulnerabilities

$ rm -rf ~/.electron ~/.cache/electron* ~/.electron-gyp ~/.npm/_libvips ~/AppData/Roaming/npm-cache/_libvips ~/.node-gyp ~/.cache/yarn/*/*sharp* node_modules

$ yarn install
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info dmg-license@1.0.8: The platform "linux" is incompatible with this module.
info "dmg-license@1.0.8" is an optional dependency and failed compatibility check. Excluding it from installation.
info iconv-corefoundation@1.1.5: The platform "linux" is incompatible with this module.
info "iconv-corefoundation@1.1.5" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ rm -rf node_modules/prebuild-install && yarn electron-builder install-app-deps
yarn run v1.22.10
$ /home/mrm/src/sharp-electron-test/node_modules/.bin/electron-builder install-app-deps
  • electron-builder  version=22.10.5
  • rebuilding native dependencies  dependencies=sharp@0.28.1 platform=linux arch=x64
  • install prebuilt binary  name=sharp version=0.28.1 platform=linux arch=x64
  ⨯ cannot find prebuild-install  
  • rebuilding native dependency  name=sharp version=0.28.1
  ⨯ cannot execute  cause=exit status 1
                    out=$ (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
    sharp: Using existing vendored libvips v8.10.6
    make: Entering directory '/home/mrm/src/sharp-electron-test/node_modules/sharp/build'
      CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
      AR(target) Release/obj.target/../node-addon-api/nothing.a
      COPY Release/nothing.a
      TOUCH Release/obj.target/libvips-cpp.stamp
      CXX(target) Release/obj.target/sharp/src/common.o
    make: Leaving directory '/home/mrm/src/sharp-electron-test/node_modules/sharp/build'
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
                    errorOut=/bin/sh: 1: prebuild-install: not found
    gyp info it worked if it ends with ok
    gyp info using node-gyp@7.1.2
    gyp info using node@14.16.0 | linux | x64
    gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
    gyp http GET https://electronjs.org/headers/v12.0.2/node-v12.0.2-headers.tar.gz
    gyp http 200 https://electronjs.org/headers/v12.0.2/node-v12.0.2-headers.tar.gz
    gyp http GET https://electronjs.org/headers/v12.0.2/SHASUMS256.txt
    gyp http 200 https://electronjs.org/headers/v12.0.2/SHASUMS256.txt
    gyp info spawn /usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/src/sharp-electron-test/node_modules/sharp/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mrm/.electron-gyp/12.0.2/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/home/mrm/.electron-gyp/12.0.2',
    gyp info spawn args   '-Dnode_gyp_dir=/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/home/mrm/.electron-gyp/12.0.2/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/home/mrm/src/sharp-electron-test/node_modules/sharp',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    ../src/common.cc:24:10: fatal error: vips/vips8: No such file or directory
       24 | #include <vips/vips8>
          |          ^~~~~~~~~~~~
    compilation terminated.
    make: *** [sharp.target.mk:145: Release/obj.target/sharp/src/common.o] Error 1
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
    gyp ERR! System Linux 5.8.0-48-generic
    gyp ERR! command "/home/mrm/.nvm/versions/node/v14.16.0/bin/node" "/home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /home/mrm/src/sharp-electron-test/node_modules/sharp
    gyp ERR! node -v v14.16.0
    gyp ERR! node-gyp -v v7.1.2
    gyp ERR! not ok 
    error Command failed with exit code 1.
    
                    command=/home/mrm/.nvm/versions/node/v14.16.0/bin/node /home/mrm/.nvm/versions/node/v14.16.0/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/home/mrm/src/sharp-electron-test/node_modules/sharp
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@mceachen
Copy link
Contributor Author

mceachen commented Apr 6, 2021

OH DEAR 🤦

My postinstall script was deleting the prebuild-install module out of node_modules: this led to prebuild-install: not found error. I don't remember why that was there, but it's clearly wrong.

I changed the postinstall to just

    "postinstall": "yarn electron-builder install-app-deps"

and everything works properly (at least on Ubuntu)

Thanks for humoring me!

@mceachen mceachen closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants