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

libvps issue in electron app #3250

Closed
3 tasks done
Stanzilla opened this issue Jun 9, 2022 · 7 comments
Closed
3 tasks done

libvps issue in electron app #3250

Stanzilla opened this issue Jun 9, 2022 · 7 comments

Comments

@Stanzilla
Copy link

Possible install-time or require-time problem

  • I have read the documentation relating to installation.
  • I have ensured that 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.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

Is this a problem with filesystem permissions?

If you are using npm v6 or earlier and installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?

If you are using npm v7 or later, does the user running npm install own the directory it is run in?

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?

What is the complete output of running npm install --verbose --foreground-scripts sharp in an empty directory?

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

I sadly can't test this because I don't have an M1 mac so I have to rely on user reports. When building the app in GitHub CI on a non M1 system, generating a universal build like this the user reports the following error on launch:

/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Resources/app.asar/node_modules/sharp/lib/sharp.js:31 Uncaught Error: 
Something went wrong installing the "sharp" module

dlopen(/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.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: /private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Resources/app.asar.unpacked/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node
  Reason: tried: '/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.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), '/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.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), '/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libvips-cpp.42.dylib' (no such file), '/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Frameworks/WeakAuras Companion Helper (Renderer).app/Contents/MacOS/../../../libvips-cpp.42.dylib' (no such file), '/usr/local/lib/libvips-cpp.42.dylib' (no such file), '/usr/lib/libvips-cpp.42.dylib' (no such file)

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --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> (/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Resources/app.asar/node_modules/sharp/lib/sharp.js:31:9)
    at Object.<anonymous> (/private/var/folders/68/70njwxb92wj7k4_2fbvm2qwm0000gn/T/AppTranslocation/C21FFB40-AB14-4498-AC48-0D03B45E1171/d/WeakAuras Companion.app/Contents/Resources/app.asar/node_modules/sharp/lib/sharp.js:34:3)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at i._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
@lovell
Copy link
Owner

lovell commented Jun 9, 2022

Did you see #678 (comment) ?

@Stanzilla
Copy link
Author

Did you see #678 (comment) ?

Yes, we do have asarUnpack set up here https://github.com/WeakAuras/WeakAuras-Companion/blob/main/vue.config.js#L45

@lovell
Copy link
Owner

lovell commented Jun 10, 2022

Thanks for confirming. If you hadn't already seen it, there's a section about cross-platform/cross-arch installations in the docs at https://sharp.pixelplumbing.com/install#cross-platform plus I've just added a multi-arch example via commit
b10d8f8

@Stanzilla
Copy link
Author

Thanks for confirming. If you hadn't already seen it, there's a section about cross-platform/cross-arch installations in the docs at sharp.pixelplumbing.com/install#cross-platform plus I've just added a multi-arch example via commit b10d8f8

Hrm I added that to our CI but now it fails with:

INFO  Building app with electron-builder:
  • electron-builder  version=23.1.0 os=21.5.0
  • rebuilding native dependencies  dependencies=sharp@0.30.6 platform=darwin arch=x64
  • install prebuilt binary  name=sharp version=0.30.6 platform=darwin arch=x64 napi= 
  • packaging       platform=darwin arch=x64 electron=19.0.4 appOutDir=dist_electron/mac-universal--x64
  • downloading     url=https://github.com/electron/electron/releases/download/v19.0.4/electron-v19.0.4-darwin-x64.zip size=82 MB parts=6
  • downloaded      url=https://github.com/electron/electron/releases/download/v19.0.4/electron-v19.0.4-darwin-x64.zip duration=2.[51](https://github.com/WeakAuras/WeakAuras-Companion/runs/6838263924?check_suite_focus=true#step:9:51)4s
  • rebuilding native dependencies  dependencies=sharp@0.30.6 platform=darwin arch=arm64
  • install prebuilt binary  name=sharp version=0.30.6 platform=darwin arch=arm64 napi= 
  • packaging       platform=darwin arch=arm64 electron=19.0.4 appOutDir=dist_electron/mac-universal--arm64
  • downloading     url=https://github.com/electron/electron/releases/download/v19.0.4/electron-v19.0.4-darwin-arm64.zip size=79 MB parts=6
  • downloaded      url=https://github.com/electron/electron/releases/download/v19.0.4/electron-v19.0.4-darwin-arm64.zip duration=3.389s
  • packaging       platform=darwin arch=universal electron=19.0.4 appOutDir=dist_electron/mac-universal
TypeError: pattern is too long
    at assertValidPattern (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/minimatch/minimatch.js:279:11)
    at minimatch (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/minimatch/minimatch.js:116:3)
    at handleFile (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/asar/lib/asar.js:123:26)
    at next (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/asar/lib/asar.js:148:11)
    at Object.module.exports.createPackageFromFiles (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/asar/lib/asar.js:1[52](https://github.com/WeakAuras/WeakAuras-Companion/runs/6838263924?check_suite_focus=true#step:9:52):10)
    at Object.module.exports.createPackageWithOptions (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/asar/lib/asar.js:40:25)
    at Object.exports.mergeASARs (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/@electron/universal/src/asar-utils.ts:198:5)
    at exports.makeUniversalApp (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/@electron/universal/src/index.ts:205:7)
    at MacPackager.doPack (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/app-builder-lib/src/macPackager.ts:125:9)
    at MacPackager.pack (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/app-builder-lib/src/macPackager.ts:191:7)
    at Packager.doBuild (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/app-builder-lib/src/packager.ts:441:9)
    at Object.executeFinally (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/builder-util/src/promise.ts:12:14)
    at Packager._build (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/app-builder-lib/src/packager.ts:3[76](https://github.com/WeakAuras/WeakAuras-Companion/runs/6838263924?check_suite_focus=true#step:9:76):31)
    at Packager.build (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/app-builder-lib/src/packager.ts:337:12)
    at Object.executeFinally (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/builder-util/src/promise.ts:12:14)
Error: Process completed with exit code 1.

which does not make sense at all to me. :(

@lovell
Copy link
Owner

lovell commented Jun 10, 2022

TypeError: pattern is too long
at assertValidPattern (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/minimatch/minimatch.js:279:11)
at minimatch (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/minimatch/minimatch.js:116:3)
at handleFile (/Users/runner/work/WeakAuras-Companion/WeakAuras-Companion/node_modules/asar/lib/asar.js:123:26)

This suggests that the asar package is not verifying filenames before passing them to its minimatch dependency.

https://github.com/electron/asar/blob/94cb8bdfea6257d7bc67f72ed80a790c2b5dae3a/lib/asar.js#L123

https://github.com/isaacs/minimatch/blob/6410ef32f59e4842121ca13eefacdf0b3da8533c/minimatch.js#L128

It looks like you've found a bug in asar - please report this downstream - this is unrelated to sharp.

@Stanzilla
Copy link
Author

Very interesting, I now added mergeASARs: false, and this made the universal binary work on m1 and intel now

@lovell
Copy link
Owner

lovell commented Jul 22, 2022

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

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