-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
The default linker in yarn 3+ is Plug'n'Play, which wraps the Node.js require
mechanics so it can control filesystem layout.
Most of the time this is a virtual filesystem built on zip files, but we know this won't work with sharp so the prebuilt binaries are already configured to be "unplugged".
sharp/npm/linux-x64/package.json
Line 16 in 004fff9
"preferUnplugged": true, |
However yarn unplugs to a directory name that contains a hash.
.yarn/unplugged/@img-sharp-libvips-linux-x64-npm-1.0.0-7dae7d64d5/...
I had assumed this was a content-based hash and therefore we wouldn't know it up-front. However it looks like it's a sha512 hash of the package scope, name and version.
$ echo -n "imgsharp-libvips-linux-x64" | sha512sum
66eeeaa2992db3c78bc9680eed56bf22325281230b955df181e137a0835f3849749df49a58b589b1d3aa3be61944322752da5426e05688eb8a64132ce3bd6531
$ echo -n "66eeeaa2992db3c78bc9680eed56bf22325281230b955df181e137a0835f3849749df49a58b589b1d3aa3be61944322752da5426e05688eb8a64132ce3bd6531npm:1.0.0" | sha512sum | head -c10
7dae7d64d5
This means we should be able to add an rpath
to satisfy yarn's Plug'n'Play filesystem layout.
Lines 176 to 179 in 004fff9
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'', | |
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'', | |
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'', | |
'-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'' |
This will result in something like (untested):
$ORIGIN/../../../../../@img-sharp-libvips-linux-x64-npm-1.0.0-7dae7d64d5/node_modules/@img/sharp-libvips-linux-x64/lib/
See 004fff9 for some discussion about this.