After upgrading both gatsby-cli
and all the gatsby-*
dependencies and plugins in the package.json
, I'm facing the following error invoking gatsby-develop
:
error UNHANDLED EXCEPTION
Error: librsvg-2.so.2: cannot enable executable stack as shared object requires: Invalid argument
- v8-compile-cache.js:159 require
[trucioli-di-legno]/[v8-compile-cache]/v8-compile-cache.js:159:20
- constructor.js:10 Object.<anonymous>
[trucioli-di-legno]/[gatsby-plugin-sharp]/[sharp]/lib/constructor.js:10:15
- v8-compile-cache.js:178 Module._compile
[trucioli-di-legno]/[v8-compile-cache]/v8-compile-cache.js:178:30
- v8-compile-cache.js:159 require
[trucioli-di-legno]/[v8-compile-cache]/v8-compile-cache.js:159:20
- index.js:3 Object.<anonymous>
[trucioli-di-legno]/[gatsby-plugin-sharp]/[sharp]/lib/index.js:3:15
- v8-compile-cache.js:178 Module._compile
[trucioli-di-legno]/[v8-compile-cache]/v8-compile-cache.js:178:30
- v8-compile-cache.js:159 require
[trucioli-di-legno]/[v8-compile-cache]/v8-compile-cache.js:159:20
Gatsby version: 1.9.183
Node.js version: 8.9.4
Operating System: Windows 10 on WSL (Ubuntu)
Any ideas on what could cause this unexpected behavior? This only occurs on the WSL substrate on Windows 10. I tested it on macOS and it works fine.
I tried to delete both node_modules
, .cache/
and build/
folders but nothing changed.
@Lc0rE This could be an issue with sharp and WSL. It looks like there's some suggested workarounds over at https://github.com/lovell/sharp-libvips/issues/3
Sorry, I forgot to mention that I tried to follow the steps proposed in the sharp issue you linked.
Trying to invoke the command execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2
gives me a execstack: cannot open "node_modules/sharp/vendor/lib/librsvg-2.so.2": No such file or directory
error because it can't find the sharp library installed.
Since, as far as I understand, gatsby-image
is relying on the sharp library to work, I'm wondering where to find the sharp module.
There is a sharp folder in node_modules/gatsby-plugin-sharp/sharp
but it doesn't contain the librsvg-2.so.2
file.
Ok apparently I solved the issue like this:
cd node_modules/gatsby-plugin-sharp
execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2
At this point, invoking gatsby develop
is giving back a Cannot find module sharp
. While I don't recall of having installed sharp manually, the following steps are solving the issue:
npm install --save sharp
Now it's working.. hope it helps!
gatsby-image
depends on gatsby-transformer-sharp
which depends on gatsby-plugin-sharp
which depends on sharp
. In case you were curious about the exact genealogy here :-)
@Lc0rE: Thanks a lot! Could this workaround be somehow added to sharp build script?
Or the underlying cause (librsvg-2.so.2) requires a library by its original ELF header?
For me this single command sufficed:
$ execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2
Current long-term fix for me is this command as postinstall
script in package.json
of the project using it:
"postinstall": "execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2"
Edit: Note: With recent sharp and node the workaround above may not be needed anymore and could cause a build error.
Most helpful comment
Ok apparently I solved the issue like this:
cd node_modules/gatsby-plugin-sharp
execstack -c node_modules/sharp/vendor/lib/librsvg-2.so.2
At this point, invoking
gatsby develop
is giving back aCannot find module sharp
. While I don't recall of having installed sharp manually, the following steps are solving the issue:npm install --save sharp
Now it's working.. hope it helps!