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 library is not being unpacked #6880

Closed
andirsun opened this issue May 20, 2022 · 10 comments
Closed

Sharp library is not being unpacked #6880

andirsun opened this issue May 20, 2022 · 10 comments
Labels

Comments

@andirsun
Copy link

  • Electron-Builder Version:
    version=23.0.9
  • Node Version:
     v14.19.0
  • Electron Version:
    ^18.1.0
  • Electron Type (current, beta, nightly):
    Current
  • Target:
    Mac / Linux / Windows

I am using the sharp library and the library is being unpacked correctly on windows and mac os builds but I have to manually unpack the library on linux with this code

linux:
  category: Graphics
  # Linux fix to use sharp library
  asarUnpack:
    - "**/node_modules/sharp/**"
@andirsun
Copy link
Author

I just donate to electron-builder org, thanks for helping me with this bug.

@mmaietta
Copy link
Collaborator

Can you please provide a minimum reproducibles repo using electron-quick-start?
I don't have a Linux machine available to test with but I'll do my best to debug it.
Glad you're able to use a workaround in the interim with asarUnpack

@andirsun
Copy link
Author

@mmaietta Let me work on it, meanwhile this the error without the workaround of unpack the library

❯ snap run streamline
A JavaScript error occurred in the main process
Uncaught Exception:
Error: 
Something went wrong installing the "sharp" module

libvips-cpp.so.42: cannot open shared object file: No such file or directory

Possible solutions:
- Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
- Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/snap/streamline/x1/resources/app.asar/node_modules/sharp/lib/sharp.js:31:9)
    at Module._compile (node:internal/modules/cjs/loader:1116:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/snap/streamline/x1/resources/app.asar/node_modules/sharp/lib/constructor.js:8:1)
    at Module._compile (node:internal/modules/cjs/loader:1116:14)

@andirsun
Copy link
Author

@mmaietta Our m1 users are reporing errors on mac os universal builds as well.
image

Uncaught Exception:
Error: 
Something went wrong installing the "sharp" module

dlopen(/Applications/Streamline.app/Contents/Resources/app.asar.unpacked/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node, 0x0001): Library not loaded: @rpath/libvips-cpp.42.dylib
Referenced from: /Applications/Streamline.app/Contents/Resources/app.asar.unpacked/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node
Reason: tried: '/Applications/Streamline.app/Contents/Resources/app.asar.unpacked/node_modules/sharp/build/Release/../.././vendor/8.12.2/darwin-arm64v8/lib/libvips-cpp.42.dylib' (no such file), '/Applications/Streamline.app/Contents/Resources/app.asar.unpacked/node_modules/sharp/build/Release/../.././vendor/8.12.2/darwin-arm64v8/lib/libvips-cpp.42.dylib' (no such file), '/Applications/Streamline.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libvips-cpp.42.dylib' (no such file), '/Applications/Streamline.app/Contents/MacOS/../Frameworks/libvips-cpp.42.dylib' (no such file), '/usr/lib/libvips-cpp.42.dylib' (no such file)

Possible solutions:
- Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
- Install for the current darwin-arm64v8 runtime: "npm install --platform=darwin --arch=arm64v8 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
at Object.<anonymous> (/Applications/Streamline.app/Contents/Resources/app.asar/node_modules/sharp/lib/sharp.js:31:9)
at Module._compile (node:internal/modules/cjs/loader:1116:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:829:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Applications/Streamline.app/Contents/Resources/

@andirsun andirsun changed the title Sharp library is not being unpacked on linux builds Sharp library is not being unpacked May 26, 2022
@mmaietta
Copy link
Collaborator

Automatic analysis (and copying) of modules is in upstream dependency https://github.com/develar/app-builder
I believe the code is found here: https://github.com/develar/app-builder/blob/master/pkg/node-modules/nodeModuleCollector.go

This can not be fixed solely through electron-builder, so you'll need to specifically it in asarUnpack to force unpack it

@goforu
Copy link

goforu commented Jun 10, 2023

Any workaround?

@andirsun
Copy link
Author

You can use resvg instead of sharp library

@Adedoyin-Emmanuel
Copy link

Adedoyin-Emmanuel commented Jun 11, 2023

Automatic analysis (and copying) of modules is in upstream dependency https://github.com/develar/app-builder I believe the code is found here: https://github.com/develar/app-builder/blob/master/pkg/node-modules/nodeModuleCollector.go

This can not be fixed solely through electron-builder, so you'll need to specifically it in asarUnpack to force unpack it

@andirsun please how do specify it in asarUnpack to force unpack it, i am using electron-react.

Here is the build property in the package.json

"build": { "productName": "Fotograph", "appId": ".app.vercel.fotograph", "asar": true, "asarUnpack": "**\\*.{node,dll}", ...others}

@Adedoyin-Emmanuel
Copy link

"/node_modules/sharp/"

Automatic analysis (and copying) of modules is in upstream dependency https://github.com/develar/app-builder I believe the code is found here: https://github.com/develar/app-builder/blob/master/pkg/node-modules/nodeModuleCollector.go
This can not be fixed solely through electron-builder, so you'll need to specifically it in asarUnpack to force unpack it

@andirsun please how do specify it in asarUnpack to force unpack it, i am using electron-react.

Here is the build property in the package.json

"build": { "productName": "Fotograph", "appId": ".app.vercel.fotograph", "asar": true, "asarUnpack": "**\\*.{node,dll}", ...others}

After making some researches and testing it, this worked for me

"asarUnpack": [ "**\\*.{node,dll}", "**/node_modules/sharp/**" ],

@MarshallChang
Copy link

Please See this : Adedoyin-Emmanuel/fotograph#1

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

No branches or pull requests

5 participants