Sharp: Install succeeds, but running fails in WSL

Created on 30 Jan 2018  路  4Comments  路  Source: lovell/sharp

Hello,

I've been trying to add Sharp to a project I'm working on.

This is the environment I'm using:

  • OS: Windows 10 Fall Creators Update (build 1709) with Windows Subsystem for Linux installed (Ubuntu from Windows Store)
  • Node version: v9.4.0

Installation goes on fine, but running it fails with the following error:

module.js:689
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: librsvg-2.so.2: cannot enable executable stack as shared object requires: Invalid argument
    at Object.Module._extensions..node (module.js:689:18)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/mnt/c/Users/Bogdan Calapod/Repos/TechLounge/harmonia/node_modules/sharp/lib/constructor.js:10:15)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)

What's interesting is that it fails on just including sharp.

What I've tried:

  • rm -rf node_modules && yarn cache clean
  • Installing libvips and libvips-dev
  • Uninstalling and reinstalling node
  • Downgrading to node v8.9.4

Steps to reproduce:

  • npm init and npm install --save sharp
  • Create a file with only const sharp = require('sharp')
  • node index.js

It will fail with the above error.

Any ideas ? Is there any debug flag that I can set to see more info about what's happening?

question

Most helpful comment

Running execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2 might fix this.

It's possible librsvg has the execstack flag set for a reason, perhaps function trampolines are used due to the mix of Rust and C sources?

I've created https://github.com/lovell/sharp-libvips/issues/3 to investigate what, if anything, can be done.

All 4 comments

A web search for "cannot enable executable stack as shared object" returns https://github.com/Microsoft/WSL/issues/286 which has some suggestions.

I've looked over the issues posted, it seems to have something to do with executable stack not being supported yet on WSL.

I tried playing around with execstack -c as the commenters suggested, but got a bit over my head. Well, I guess it's a WSL issue, not a sharp one after all.

Thanks for your effort!

Running execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2 might fix this.

It's possible librsvg has the execstack flag set for a reason, perhaps function trampolines are used due to the mix of Rust and C sources?

I've created https://github.com/lovell/sharp-libvips/issues/3 to investigate what, if anything, can be done.

This worked wonders for me on a Windows installation...

set GYP_MSVS_VERSION=2015
npm install --msvs_version=2015
npm install node-gyp -g
npm install sharp

Using Yarn?
I went into a different directory and just installed it there, it's all global so it works. Also did this so it wouldn't conflict with my yarn node_modules folder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomercagan picture tomercagan  路  3Comments

emmtte picture emmtte  路  3Comments

Andresmag picture Andresmag  路  3Comments

terbooter picture terbooter  路  3Comments

vermin1337 picture vermin1337  路  3Comments