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

Sharp with electron-boilerplate not working in packaged release #2818

Closed
sarang-apps opened this issue Jul 29, 2021 · 4 comments
Closed

Sharp with electron-boilerplate not working in packaged release #2818

sarang-apps opened this issue Jul 29, 2021 · 4 comments

Comments

@sarang-apps
Copy link

sarang-apps commented Jul 29, 2021

Pre checks

Did you see the documentation relating to installation?
Yes

Have you ensured the architecture and platform of Node.js used for npm install is the same as the architecture and platform of Node.js used at runtime?
Yes

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
Yes

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?

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

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 821.71 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash

  Binaries:
    Node: 15.4.0 - ~/.nvm/versions/node/v15.4.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v15.4.0/bin/yarn
    npm: 7.20.1 - [`~/.nvm/versions/node/v15.4.0/bin/npm`](url)

Steps to Reproduce Issue

  1. I used this template:
    https://github.com/electron-react-boilerplate/electron-react-boilerplate

  2. and created a repo:
    https://github.com/sarang-apps/sharp_test

  3. Then I went into "/src" folder and did yarn add sharp and the output was :

yarn add v1.22.10
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ sharp@0.28.3
info All dependencies
└─ sharp@0.28.3
$ yarn electron-rebuild
yarn run v1.22.10
$ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
⠏ Building modules: 0/1gyp info find Python using Python version 3.9.6 found at "/usr/local/opt/python@3.9/bin/python3.9"
⠋ Building modules: 0/1gyp http GET https://www.electronjs.org/headers/v11.0.1/node-v11.0.1-headers.tar.gz
⠹ Building modules: 0/1gyp http 200 https://www.electronjs.org/headers/v11.0.1/node-v11.0.1-headers.tar.gz
⠹ Building modules: 0/1gyp http GET https://www.electronjs.org/headers/v11.0.1/SHASUMS256.txt
⠼ Building modules: 0/1gyp http 200 https://www.electronjs.org/headers/v11.0.1/SHASUMS256.txt
gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/computerroom/Desktop/repos/sharp_test/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   '/Users/computerroom/Desktop/repos/sharp_test/src/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/computerroom/Desktop/repos/sharp_test/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/computerroom/Desktop/repos/sharp_test/src/node_modules/sharp/11.0.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/computerroom/Desktop/repos/sharp_test/src/node_modules/sharp/11.0.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/computerroom/Desktop/repos/sharp_test/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/computerroom/Desktop/repos/sharp_test/src/node_modules/sharp/11.0.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/computerroom/Desktop/repos/sharp_test/src/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 ]
⠇ Building modules: 0/1gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
⠏ Building modules: 0/1  LIBTOOL-STATIC Release/nothing.a
⠋ Building modules: 0/1  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
⠹ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/metadata.o
⠙ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/stats.o
⠏ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/operations.o
⠸ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/pipeline.o
⠴ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/utilities.o
⠏ Building modules: 0/1  CXX(target) Release/obj.target/sharp/src/sharp.o
⠹ Building modules: 0/1  SOLINK_MODULE(target) Release/sharp.node
✔ Rebuild Complete
✨  Done in 24.79s.
✨  Done in 46.48s.
  1. Then went to src/App.tsx
  • imported Sharp and console.log(sharp.format);
  1. Run yarn start
  • And it runs perfectly fine.
  1. Then I run yarn package and it creates the release files. Then I went to the actual file and run the ElectronReact App in the mac folder.
  • Then it doesn't run properly and returns just the background.
  1. Then I run a debugger on it using:
    ElectronReact.app/Contents/MacOS/ElectronReact --remote-debugging-port=8315
    in terminal after cd into the folder.
  • In the console I get:
Something went wrong installing the "sharp" module

dlopen(/var/folders/sh/51kq204971b7dj984196l3880000gn/T/.org.erb.ElectronReact.9bczRx, 1): no suitable image found.  Did find:
	/var/folders/sh/51kq204971b7dj984196l3880000gn/T/.org.erb.ElectronReact.9bczRx: code signature in (/var/folders/sh/51kq204971b7dj984196l3880000gn/T/.org.erb.ElectronReact.9bczRx) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
	/var/folders/sh/51kq204971b7dj984196l3880000gn/T/.org.erb.ElectronReact.9bczRx: stat() failed with errno=17

- Remove the "node_modules/sharp" directory then run
  "npm install --ignore-scripts=false --verbose sharp" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/install
- Search for this error at https://github.com/lovell/sharp/issues

    at Object.<anonymous> (/Users/computerroom/Desktop/repos/sharp_test/release/mac/ElectronReact.app/Contents/Resources/app.asar/node_modules/sharp/lib/constructor.js:32)
    at Object.<anonymous> (/Users/computerroom/Desktop/repos/sharp_test/release/mac/ElectronReact.app/Contents/Resources/app.asar/node_modules/sharp/lib/constructor.js:394)
    at Module._compile (internal/modules/cjs/loader.js:1152)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173)
    at Module.load (internal/modules/cjs/loader.js:992)
    at Module._load (internal/modules/cjs/loader.js:885)
    at Function.f._load (electron/js2c/asar_bundle.js:5)
    at Module.require (internal/modules/cjs/loader.js:1032)
    at require (internal/modules/cjs/helpers.js:72)
    at Object.<anonymous> (/Users/computerroom/Desktop/repos/sharp_test/release/mac/ElectronReact.app/Contents/Resources/app.asar/node_modules/sharp/lib/index.js:3)

So I am facing this issue with sharp in the packaged project, but in dev it is working fine.
The reproduced error is in the project:
https://github.com/sarang-apps/sharp_test

I also have libvips installed on my computer so there are no issues with that.

@lovell
Copy link
Owner

lovell commented Jul 29, 2021

This is probably the same as #2764. Avoid running electron-rebuild if possible as it currently causes problems with native modules that use Node-API.

@sarang-apps
Copy link
Author

I removed electron-rebuild but it still has the same issue. Let me know if you find any other solution to this.

@lovell
Copy link
Owner

lovell commented Aug 2, 2021

I removed electron-rebuild but it still has the same issue.

Please can you update https://github.com/sarang-apps/sharp_test to remove use of electron-rebuild to allow someone else to reproduce.

@lovell
Copy link
Owner

lovell commented Jul 27, 2022

Let's track this at #2764

@lovell lovell closed this as completed Jul 27, 2022
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