8000 Enhancement: Support yarn Plug'n'Play · Issue #3888 · lovell/sharp · GitHub
[go: up one dir, main page]

Skip to content
Enhancement: Support yarn Plug'n'Play #3888
@lovell

Description

@lovell

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".

"preferUnplugged": true,

https://github.com/lovell/sharp-libvips/blob/9835b9e1326f38ebdd8b26554aa5e936b8485865/npm/linux-x64/package.json#L16

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.

sharp/src/binding.gyp

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0