gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

GLib-GObject-CRITICAL error with last gatsby-transformer-sharp #16957

Closed tjands closed 5 years ago

tjands commented 5 years ago

Description

Hey all, Since I updated all of my packages I have been unable to run gatsby develop nor gatsby build. The builder is able run all of my static and page queries and then fails once it reaches the start webpack server process. I have tried reinstalling all of my node modules, updating glib through brew, I've also tried to run on several different environments.

(Other OSX computers are getting the same error for me, whilst my Ubuntu machine can run develop and build fine)

Actual result

Once gatsby develop gets to start webpack server it throws the following as errors and then the develop process stops.

(sharp:65167): GLib-GObject-WARNING **: 16:35:38.095: cannot register existing type 'VipsObject'

(sharp:65167): GLib-CRITICAL **: 16:35:38.095: g_once_init_leave: assertion 'result != 0' failed

(sharp:65167): GLib-GObject-CRITICAL **: 16:35:38.095: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:65167): GLib-CRITICAL **: 16:35:38.095: g_once_init_leave: assertion 'result != 0' failed

Environment

System: OS: macOS 10.14.6 CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz Shell: 5.3 - /bin/zsh Binaries: Node: 10.16.3 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/local/bin/python Browsers: Chrome: 76.0.3809.100 Safari: 12.1.2 npmPackages: gatsby: ^2.13.72 => 2.13.75 gatsby-background-image: ^0.8.5 => 0.8.5 gatsby-graphiql-explorer: ^0.2.4 => 0.2.6 gatsby-image: ^2.2.10 => 2.2.11 gatsby-plugin-catch-links: ^2.1.4 => 2.1.4 gatsby-plugin-favicon: ^3.1.6 => 3.1.6 gatsby-plugin-feed: ^2.3.7 => 2.3.7 gatsby-plugin-google-analytics: ^2.1.8 => 2.1.8 gatsby-plugin-humans-txt: ^1.1.3 => 1.1.3 gatsby-plugin-manifest: ^2.2.6 => 2.2.8 gatsby-plugin-no-sourcemaps: ^2.1.1 => 2.1.1 gatsby-plugin-offline: ^2.2.7 => 2.2.9 gatsby-plugin-page-transitions: ^1.0.8 => 1.0.8 gatsby-plugin-react-helmet: ^3.1.4 => 3.1.4 gatsby-plugin-s3: ^0.3.2 => 0.3.2 gatsby-plugin-sass: ^2.1.10 => 2.1.11 gatsby-plugin-sharp: ^2.2.15 => 2.2.15 gatsby-plugin-styled-components: ^3.1.2 => 3.1.2 gatsby-plugin-transition-link: ^1.12.4 => 1.12.4 gatsby-remark-copy-linked-files: ^2.1.7 => 2.1.9 gatsby-remark-images: ^3.1.13 => 3.1.15 gatsby-remark-prismjs: ^3.3.6 => 3.3.7 gatsby-remark-responsive-iframe: ^2.2.5 => 2.2.7 gatsby-remark-smartypants: ^2.1.3 => 2.1.4 gatsby-source-filesystem: ^2.1.10 => 2.1.13 gatsby-source-instagram: ^0.5.1 => 0.5.1 gatsby-transformer-remark: ^2.6.15 => 2.6.17 gatsby-transformer-sharp: ^2.2.7 => 2.2.9 npmGlobalPackages: gatsby-cli: 2.7.36 gatsby: 2.13.75

Any help would be fantastic

antoinerousseau commented 5 years ago

Try adding these at the top of your gatsby-nodes.js:

const sharp = require('sharp')
sharp.simd(false)
sharp.cache(false)

See https://github.com/gatsbyjs/gatsby/issues/6291#issuecomment-509783902

klgh commented 5 years ago

Try adding these at the top of your gatsby-nodes.js:

const sharp = require('sharp')
sharp.simd(false)
sharp.cache(false)

See #6291 (comment)

I just tried this and am still having the same error:

(sharp:44423): GLib-GObject-WARNING **: 11:24:41.418: cannot register existing type 'VipsObject'

(sharp:44423): GLib-CRITICAL **: 11:24:41.418: g_once_init_leave: assertion 'result != 0' failed

(sharp:44423): GLib-GObject-CRITICAL **: 11:24:41.418: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:44423): GLib-CRITICAL **: 11:24:41.418: g_once_init_leave: assertion 'result != 0' failed
RomanHotsiy commented 5 years ago

I have a similar issue after upgrading on OSX.

May be related to https://github.com/gatsbyjs/gatsby/issues/9751

jrusso1020 commented 5 years ago

Also experiencing this issue locally on OSX as well as on my CircleCI build which is running on a linux container. They seem to fail in different locations though?

Locally I get

success open and validate gatsby-configs - 0.080 s
⠋ load plugins

(sharp:63077): GLib-GObject-WARNING **: 12:28:35.427: cannot register existing type 'VipsObject'

(sharp:63077): GLib-CRITICAL **: 12:28:35.433: g_once_init_leave: assertion 'result != 0' failed

(sharp:63077): GLib-GObject-CRITICAL **: 12:28:35.433: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:63077): GLib-CRITICAL **: 12:28:35.433: g_once_init_leave: assertion 'result != 0' failed

But on CircleCI I get

success open and validate gatsby-configs — 0.068
success load plugins — 1.233
success onPreInit — 0.016
success delete html and css files from previous builds — 0.020
success initialize cache — 0.031
success copy gatsby files — 0.039
success onPreBootstrap — 0.024
success source and transform nodes — 0.250
success Add explicit types — 0.029
success Add inferred types — 0.152
success Processing types — 0.152
success building schema — 0.511
success createPages — 0.068
success createPagesStatefully — 0.044
success onPreExtractQueries — 0.015
success update schema — 0.070
success extract queries from components — 0.403
success write out requires — 0.014
success write out redirect data — 0.017
warning The icon(static/images/profile-pic.jpg) you provided to 'gatsby-plugin-manifest' is not square.
The icons we generate will be square and for the best results we recommend you provide a square icon.

node: symbol lookup error: /home/circleci/anakin/node_modules/sharp/build/Release/sharp.node: nodeundefined symbol: _ZN4vips6VImage8jpegloadEPKcPNS_7VOptionE
: symbol lookup error: /home/circleci/anakin/node_modules/sharp/build/Release/sharp.nodenpm ERR! file sh
RomanHotsiy commented 5 years ago

Downgrading to gatsby-plugin-sharp@2.2.14 fixes the issue.

jrusso1020 commented 5 years ago

Downgrading to gatsby-plugin-sharp@2.2.12 fixes the issue.

Yes I was going to say I believe this error actually started to happen once I upgrade gatsby-plugin-sharp not gatsby-transformer-sharp, so downgrading should fix the issue temporarily until the package is fixed

hhimanshu commented 5 years ago

I guess, it is more than downgrading gatsby-plugin-sharp@2.2.12. Here is the info for my project and downgrading still fails


  System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 11.14.0 - ~/.nvm/versions/node/v11.14.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v11.14.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 76.0.3809.100
    Safari: 12.1.2
  npmPackages:
    gatsby: ^2.13.76 => 2.13.76 
    gatsby-image: ^2.0.15 => 2.2.10 
    gatsby-plugin-favicon: ^3.1.4 => 3.1.6 
    gatsby-plugin-offline: ^2.2.9 => 2.2.9 
    gatsby-plugin-react-helmet: ^3.0.0 => 3.1.4 
    gatsby-plugin-sharp: ^2.2.12 => 2.2.16 
    gatsby-plugin-styled-components: ^3.0.1 => 3.1.2 
    gatsby-source-filesystem: ^2.0.4 => 2.1.11 
    gatsby-transformer-sharp: ^2.2.10 => 2.2.10 
  npmGlobalPackages:
    gatsby-cli: 2.7.30

To be precise what I did, I used @dependabot to upgrade dependencies for my project and following pull-requests were offered to me

https://github.com/bonsaiilabs/gatsby-material-ui-storybook-starter/pulls?q=is%3Apr+is%3Aclosed

After downgrading

 gatsby-plugin-sharp: ^2.2.12 => 2.2.16 

I still face the isse when I run yarn start.

yarn run v1.17.3
$ gatsby develop -H 0.0.0.0
success open and validate gatsby-configs - 0.061 s
success load plugins - 0.921 s
success onPreInit - 0.034 s
success initialize cache - 0.046 s
success copy gatsby files - 0.122 s
success onPreBootstrap - 0.038 s
success source and transform nodes - 0.288 s
success Add explicit types - 0.041 s
success Add inferred types - 0.237 s
success Processing types - 0.148 s
success building schema - 0.543 s
success createPages - 0.028 s
success createPagesStatefully - 0.107 s
success onPreExtractQueries - 0.031 s
success update schema - 0.060 s
success extract queries from components - 0.565 s
success write out requires - 0.092 s
success write out redirect data - 0.028 s
success onPostBootstrap - 0.025 s
⠀
info bootstrap finished - 6.614 s
⠀
success run static queries - 0.025 s
success run page queries - 0.107 s — 5/5 62.04 queries/second
⠙ start webpack server

(sharp:52830): GLib-GObject-WARNING **: 11:05:29.202: cannot register existing type 'VipsObject'

(sharp:52830): GLib-CRITICAL **: 11:05:29.202: g_once_init_leave: assertion 'result != 0' failed

(sharp:52830): GLib-GObject-CRITICAL **: 11:05:29.202: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:52830): GLib-CRITICAL **: 11:05:29.202: g_once_init_leave: assertion 'result != 0' failed
klgh commented 5 years ago

I downgraded these since they were upgraded yesterday as well and am still getting the same error.

`"gatsby-plugin-sharp": "^2.2.12",

"gatsby-remark-images": "^3.1.14", "gatsby-source-filesystem": "^2.1.12", "gatsby-transformer-remark": "^2.6.16", "gatsby-transformer-sharp": "^2.2.8",`

Here's my full system info:

` System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: 5.3 - /bin/zsh

Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm

Languages: Python: 2.7.10 - /usr/bin/python

Browsers: Chrome: 76.0.3809.100 Firefox: 68.0.1 Safari: 12.1.2

npmPackages: gatsby: ^2.13.76 => 2.13.76 gatsby-cli: ^2.7.37 => 2.7.37 gatsby-image: ^2.2.12 => 2.2.12 gatsby-plugin-catch-links: ^2.1.4 => 2.1.4 gatsby-plugin-categories: ^2.3.5 => 2.3.5 gatsby-plugin-disqus: ^1.1.2 => 1.1.2 gatsby-plugin-draft: 0.0.4 => 0.0.4 gatsby-plugin-favicon: ^3.1.6 => 3.1.6 gatsby-plugin-feed: ^2.3.7 => 2.3.7 gatsby-plugin-google-analytics: ^2.1.9 => 2.1.9 gatsby-plugin-manifest: ^2.2.8 => 2.2.8 gatsby-plugin-offline: ^2.2.9 => 2.2.9 gatsby-plugin-prefetch-google-fonts: ^1.4.3 => 1.4.3 gatsby-plugin-react-helmet: ^3.1.4 => 3.1.4 gatsby-plugin-sass: ^2.1.11 => 2.1.11 gatsby-plugin-sharp: ^2.2.12 => 2.2.16 gatsby-plugin-sitemap: ^2.2.8 => 2.2.8 gatsby-plugin-tags: ^2.3.5 => 2.3.5 gatsby-remark-external-links: 0.0.4 => 0.0.4 gatsby-remark-images: ^3.1.14 => 3.1.16 gatsby-source-filesystem: ^2.1.12 => 2.1.14 gatsby-transformer-remark: ^2.6.16 => 2.6.18 gatsby-transformer-sharp: ^2.2.8 => 2.2.10 `

RomanHotsiy commented 5 years ago

@hhimanshu @klgh

You both look to not downgrade actually, the version range you specify "gatsby-plugin-sharp": "^2.2.12" includes 2.2.16. You can even see that in npmPackages output:

gatsby-plugin-sharp: ^2.2.12 => 2.2.16 - notice, that 2.2.16 is actually used.

Try pinpointing it directly to "2.2.12".

Also, you may try removing yarn.lock or npm-lock.json and node_modules and install deps again.

hhimanshu commented 5 years ago

@RomanHotsiy, 🥇 thanks a ton for pointing that out. I confirm that by replacing the version in package.json as below, things started to work

    "gatsby-plugin-sharp": "2.2.12",

The gatsby info --clipboard is following


  System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 11.14.0 - ~/.nvm/versions/node/v11.14.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v11.14.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 76.0.3809.100
    Safari: 12.1.2
  npmPackages:
    gatsby: ^2.13.76 => 2.13.76 
    gatsby-image: ^2.2.12 => 2.2.12 
    gatsby-plugin-favicon: ^3.1.4 => 3.1.6 
    gatsby-plugin-offline: ^2.2.9 => 2.2.9 
    gatsby-plugin-react-helmet: ^3.0.0 => 3.1.4 
    gatsby-plugin-sharp: 2.2.12 => 2.2.12 
    gatsby-plugin-styled-components: ^3.0.1 => 3.1.2 
    gatsby-source-filesystem: ^2.0.4 => 2.1.11 
    gatsby-transformer-sharp: ^2.2.10 => 2.2.10 
  npmGlobalPackages:
    gatsby-cli: 2.7.30
klgh commented 5 years ago

woo, that worked! thanks so much @RomanHotsiy!

RomanHotsiy commented 5 years ago

I dig a bit more and it looks to start crashing starting from gatsby-plugin-sharp@2.2.15 so temporary downgrading to gatsby-plugin-sharp@2.2.14 will do a trick.

It looks to be caused by upgrading sharp from ^0.22.1 to ^0.23.0

I event don't know who to @ mention here as this PR was created by @renovate-bot and merged by @gatsbybot 😄

KyleAMathews commented 5 years ago

Could people try running npm rebuild?

sidharthachatterjee commented 5 years ago

@lovell Does the error above look familiar?

sidharthachatterjee commented 5 years ago

@RomanHotsiy Thanks for investigating! Let's wait on @lovell (Sharp maintainer) to see if this is a known issue before we merge in https://github.com/gatsbyjs/gatsby/pull/16971

In the mean time, sorry for the trouble, folks! Please use gatsby-plugin-sharp@2.2.14 or set the following in your package.json (when using yarn)

  "resolutions": {
    "sharp": "0.22.1"
  }
jrusso1020 commented 5 years ago

Could people try running npm rebuild?

npm rebuild with gatsby-plugin-sharp => 2.2.16, seems to have fixed the problem locally for my OSX builds as well as on CircleCI for my linux builds. I had to add it to my .circleci/config.yml but everything seems to be working after rebuilding

sidharthachatterjee commented 5 years ago

@jrusso1020 If that's the case then this is not a bug since rebuilding is necessary for native modules and sharp is one.

Not sure why it isn't rebuilt at postinstall though

I had to add it to my .circleci/config.yml

This shouldn't be necessary unless your node_modules were cached from an old build which needed to be rebuilt

jrusso1020 commented 5 years ago

@sidharthachatterjee I think the problem is that sharp was cached and when using npm install it internally uses npm build and the postinstall scripts will use the npm cached values,npm rebuild will not use the cached values

You're right though about CircleCI, I'm not sure why I had problems there

sidharthachatterjee commented 5 years ago

You're right though about CircleCI, I'm not sure why I had problems there

You were probably caching node_modules on CircleCI, I would guess. That would cause this.

Anyway, looks like this isn't a bug then. Still keeping this open for a while until the issue author and others are good! 🙂

lovell commented 5 years ago

The cannot register existing type 'VipsObject' message suggests two different versions of the libvips shared libraries are being used in the same node process, which might suggest that both sharp v0.22.x and v0.23.x are in the dependency tree.

If so, please see https://github.com/lovell/sharp/issues/1680#issuecomment-487701749 for some previous advice on how Gatsby might be able to manage this.

tjands commented 5 years ago

rolling back to 2.2.12 on gatsby-plugin-sharp got me back up and running too @RomanHotsiy;

Thanks for all the ongoing support everyone😻

tjands commented 5 years ago

This is looking resolved with the latest release for gatsby and version 2.2.16. Thanks all, and happy to close this :)

sidharthachatterjee commented 5 years ago

The cannot register existing type 'VipsObject' message suggests two different versions of the libvips shared libraries are being used in the same node process, which might suggest that both sharp v0.22.x and v0.23.x are in the dependency tree.

@lovell Hope all is well with you and thank you for the quick response.

Opened a new issue in https://github.com/gatsbyjs/gatsby/issues/16985 to track this so we can improve the experience for the next time vips is upgraded. We do some handling in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-sharp/src/safe-sharp.js but need to handle this edge case as well I think.

Thanks everyone!

benday280412 commented 5 years ago

Hi guys,

I'm afraid that I'm still experiencing this issue.

I've tried the latest version of the libraries in question, as well as a number of permutations in between. I've also tried clearing node_modules and npm rebuild, but still can't get past this one.

gatsby info

System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 3.7.0 - /usr/local/bin/python
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 68.0.1
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.9.0 => 2.13.82
    gatsby-image: ^2.1.3 => 2.2.14
    gatsby-link: ^2.1.1 => 2.2.9
    gatsby-plugin-catch-links: ^2.0.15 => 2.1.5
    gatsby-plugin-facebook-pixel: ^1.0.3 => 1.0.3
    gatsby-plugin-feed: ^2.2.3 => 2.3.9
    gatsby-plugin-google-analytics: ^2.0.21 => 2.1.11
    gatsby-plugin-google-tagmanager: ^2.0.15 => 2.1.7
    gatsby-plugin-manifest: ^2.1.1 => 2.2.9
    gatsby-plugin-nprogress: ^2.0.10 => 2.1.4
    gatsby-plugin-offline: ^2.1.1 => 2.2.10
    gatsby-plugin-preact: ^3.0.0 => 3.1.6
    gatsby-plugin-react-helmet: ^3.0.12 => 3.1.5
    gatsby-plugin-s3: ^0.3.2 => 0.3.2
    gatsby-plugin-sass: ^2.0.11 => 2.1.12
    gatsby-plugin-sharp: 2.2.16 => 2.2.16
    gatsby-plugin-sitemap: ^2.1.0 => 2.2.9
    gatsby-plugin-twitter: ^2.0.13 => 2.1.4
    gatsby-plugin-web-font-loader: ^1.0.4 => 1.0.4
    gatsby-remark-autolink-headers: ^2.0.16 => 2.1.7
    gatsby-remark-component: ^1.1.3 => 1.1.3
    gatsby-remark-copy-linked-files: ^2.0.13 => 2.1.11
    gatsby-remark-external-links: ^0.0.4 => 0.0.4
    gatsby-remark-images: ^3.0.14 => 3.1.18
    gatsby-remark-images-contentful: ^2.0.12 => 2.1.10
    gatsby-remark-lazy-load: ^1.0.1 => 1.0.1
    gatsby-remark-responsive-iframe: ^2.1.1 => 2.2.8
    gatsby-remark-smartypants: ^2.0.9 => 2.1.5
    gatsby-source-contentful: ^2.0.67 => 2.1.28
    gatsby-source-filesystem: ^2.0.39 => 2.1.17
    gatsby-source-wordpress: ^3.0.65 => 3.1.24
    gatsby-transformer-json: ^2.1.11 => 2.2.5
    gatsby-transformer-remark: ^2.3.12 => 2.6.19
    gatsby-transformer-sharp: 2.2.12 => 2.2.12

It doesn't look like there are any conflicting versions of sharp in the tree, see below.

npm list sharp

├─┬ gatsby-plugin-manifest@2.2.9
│ └── sharp@0.23.0
├─┬ gatsby-plugin-sharp@2.2.16
│ └── sharp@0.23.0  deduped
├─┬ gatsby-remark-images-contentful@2.1.10
│ └── sharp@0.23.0  deduped
├─┬ gatsby-source-contentful@2.1.28
│ └─┬ gatsby-plugin-sharp@2.2.18
│   └── sharp@0.23.0  deduped
└─┬ gatsby-transformer-sharp@2.2.12
  └── sharp@0.23.0  deduped

Any ideas on where to go next?

benday280412 commented 5 years ago

I can confirm that rolling all dependencies that make sure of Sharp to ones that use 0.21.1 avoids the issue, but clearly, this is not a long term solution.

npm list sharp 

├─┬ gatsby-plugin-manifest@2.2.6
│ └── sharp@0.22.1
├─┬ gatsby-plugin-sharp@2.2.13
│ └── sharp@0.22.1
├─┬ gatsby-remark-images-contentful@2.1.5
│ └── sharp@0.22.1  deduped
└─┬ gatsby-transformer-sharp@2.2.7
  └── sharp@0.22.1  deduped
hillsng commented 5 years ago

I have this same issue and none of these suggestions has worked for me...I see reference to gatsby-plugin-sharp but we are not using this plugin anywhere. however I have added this and still yet not working.... Could someone please help:

success run static queries - 0.098 s — 6/6 84.00 queries/second success run page queries - 1.525 s — 70/70 46.86 queries/second ⠙ start webpack server

(sharp:19129): GLib-GObject-WARNING **: 13:45:01.948: cannot register existing type 'VipsObject'

(sharp:19129): GLib-CRITICAL **: 13:45:01.948: g_once_init_leave: assertion 'result != 0' failed

(sharp:19129): GLib-GObject-CRITICAL **: 13:45:01.948: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:19129): GLib-CRITICAL **: 13:45:01.948: g_once_init_leave: assertion 'result != 0' failed

klgh commented 5 years ago

Is anyone having issues deploying to netlify? I fixed the issue, so it runs locally, but netlify won't build.

pepicrft commented 5 years ago

Same here, I get the following error on Netlify:

6:45:56 PM: Cannot find module '../build/Release/sharp.node'
6:45:56 PM: - Remove the "node_modules/sharp" directory, run "npm install" and look for errors
6:45:56 PM: - Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
6:45:56 PM: - Search for this error at https://github.com/lovell/sharp/issues
janosh commented 5 years ago

Thanks @sidharthachatterjee! Appending

"resolutions": {
  "sharp": "0.22.1"
}

to package.json and reinstalling node_modules worked as a temporary fix.

May I suggest that this issue be reopened as long as people are still running into it?

RomainCscn commented 5 years ago

Same issue on Netlify. Try downgrading gatsby-plugin-sharp but still not working.

jcursoli commented 5 years ago

I had the same issue on Netlify but got it working by:

1) downgrade gatsby-plugin-sharp to 2.2.14 (gatsby-plugin-sharp@2.2.14) 2) rm package-lock.json 3) rm yarn.lock

then push your changes. if the build fails again then in netlify you will have to click on the failed build click on retry deploy then Clear cache and deploy site

LekoArts commented 5 years ago

Whats your installed libvips version? And please try running npm rebuild, your issues occur most likely due to the fact that your newly installed binary doesn't work with the installed libvips version on your machine. There should be no need to downgrade the version of gatsby plugins :)

b4stien commented 5 years ago

I'm not really sure we've found the real cause of this issue, https://github.com/gatsbyjs/gatsby/issues/16957#issuecomment-526824124 worked for us but we're now stuck with sharp 0.22.1 (and warnings).

None of the above suggestions (npm rebuild mainly) worked on our end.

benshell commented 5 years ago

I just had this problem after upgrading an old project (a few months old). What seems to have worked around it for me was switching to Yarn, with the resolutions config above (https://github.com/gatsbyjs/gatsby/issues/16957#issuecomment-526824124) and then:

rm -rf node_modules/sharp/vendor
yarn install
yarn upgrade
yarn start
dcsan commented 5 years ago

I'm getting identical problems here with latest versions of related plugins

    "gatsby-plugin-sharp": "^2.2.24",
memoev commented 5 years ago

I confirm downgrading the packages worked for me. specifically the sharp pkg:

npm i gatsby-plugin-sharp@2.2.9
npm i gatsby-transformer-sharp@2.2.5

I remember to actually run the bash commands on my terminal to set up my package-lock.json correctly. I guess this means something breaks with the packages upgrade.

dcsan commented 5 years ago

I documented a fix for this on some other ticket. basically it's caused by two mismatching versions of 'sharp' which are deps of other packages.

npm up
npm ls sharp

fixed it for me at least

janosh commented 5 years ago

@LekoArts Should this really be closed? Seems like this is an ongoing issue.

dcsan commented 5 years ago

solution here: https://github.com/gatsbyjs/gatsby/issues/9751#issuecomment-533702498

npm up
npm ls sharp

check you don't have any version mismatches with sharp.

janosh commented 5 years ago

@dcsan I would call that a workaround rather than a solution since people will keep running into this problem if it requires manual work to avoid. Also, what would be the yarn equivalent to this? I tried yarn upgrade but that didn't work for me, resulting in continued version mismatch:

➜  yarn list --pattern sharp
yarn list v1.17.3
├─ favicons@5.4.1
│  └─ sharp@0.22.1
├─ gatsby-plugin-sharp@2.2.27
├─ gatsby-transformer-sharp@2.2.19
└─ sharp@0.23.1
dcsan commented 5 years ago

well that's unfortunate that favicons still seems stuck on an old sharp. perhaps it's down to the semver upgrade funnily enough I have favicons working in my project, but without that dependency.

As far as I can tell it's a very deep problem to have two versions of sharp co-existing. We're dependent on the packages updating to use the same sub-deps of sharp.

also FWIW I stopped using yarn because of various problems with C extensions and native compiling. npm also has a cache now so i think the speed difference isn't so noticeable.

I just installed latest favicons and indeed get that same problem.

➜  dc.rik.ai git:(master) ✗ yarn list --pattern sharp
yarn list v1.17.3
├─ favicons@5.4.1
│  └─ sharp@0.22.1
├─ gatsby-plugin-sharp@2.2.27
├─ gatsby-transformer-sharp@2.2.19
└─ sharp@0.23.1
✨  Done in 8.55s.

my app will still start but I guess it's because of the image cache or sharp not getting triggered.

➜  dc.rik.ai git:(master) ✗ rm -rf .cache
➜  dc.rik.ai git:(master) ✗ npm start

however still starts... so it's hard to even know how to trigger this nasty problem. probably running the whole install process again.

from my side I just removed the favicons package for now, as I seem to have favicons anyway.

sidharthachatterjee commented 5 years ago

So to summarise, it appears that we're hitting this when multiple versions of sharp are encountered. When this is with other dependencies (like favicons), we can't really control that.

However, we should probably improve the experience if people are hitting this using multiple gatsby plugins (like gatsby-plugin-sharp and gatsby-plugin-manifest)

Let's track that in https://github.com/gatsbyjs/gatsby/issues/16985

Since the original issue opened by the author here seems to be resolved, I'm closing this issue for now. Thank you all of you for participating in this and have a great weekend 🎉

ironcove commented 5 years ago

I spent 2 days on this issue and here's how I finally found salvation

$ npm i node@10.15.3 -g

Then I had GLib GObject-CRITICAL errors and I checked for different versions of sharp using

$ npm up

and

$ npm ls sharp

In the end I believe from my google searching that the issue resides with different versions of sharp

before

I looked at the gatsby-transformer-sharp and it's version was off so I saw in the repo that it has the correct version of sharp but my gatsby-transformer-sharp was an older version. I upgraded to

$ npm i gatsby-transformer-sharp@2.3.2

new sharps are matching up

kuworking commented 5 years ago

In my case, I have

"gatsby-transformer-sharp": "^2.3.5",
"gatsby-plugin-sharp": "^2.3.0",

that both use

 "sharp": "^0.23.2"

which is indeed the version in node_modules

yarn list --pattern sharp
yarn list v1.19.0
├─ gatsby-plugin-sharp@2.3.0
├─ gatsby-transformer-sharp@2.3.5
└─ sharp@0.23.2

I also have in gatsby_node

const sharp = require('sharp')
sharp.cache(false)
sharp.simd(false)

And I have deleted node_modules, yarn.lock and run yarn again, and done npm rebuilt as well (I'm in yarn workspaces)

gatsby build fails

 [=======-----------------------] 4695/20646 228.2 s 22% Generating image thumbnailsException code=0xc0000005 flags=0x0 at 0x000000005EBD2994. Access violation - attempting to read data at address 0x0000000000000271
error Command failed with exit code 3221225477.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 3221225477
Command: C:\Program Files\nodejs\node.exe

*I'm in yarn workspaces

*Just updated in https://github.com/gatsbyjs/gatsby/issues/16985 since that issue is the one I think remains open for this issue

macandcheese commented 4 years ago

For me the issue was gatsby-plugin-favicon depending on a different version of sharp:

├─┬ gatsby-plugin-favicon@3.1.6
│ └─┬ favicons-webpack-plugin@0.0.9 (git+https://github.com/Creatiwity/favicons-webpack-plugin.git#0872de414061baaad0a2853c77ae75bc38b8bbbf)
│   └─┬ favicons@5.4.1
│     └── sharp@0.22.1
├─┬ gatsby-plugin-manifest@2.2.29
│ └── sharp@0.23.3 
├─┬ gatsby-plugin-sharp@2.3.3
│ └── sharp@0.23.3 
└── sharp@0.23.3 

Removing that plugin solved my issue with this...

xpzouying commented 4 years ago

I had same issues on ubuntu 18.04, then I run the following step:

  1. delete package-lock.json
  2. use yarn
  3. apt install libglu1 libxi-dev

It works for me.

gvdp commented 4 years ago

Was experiencing the same issues, working with yarn as package manager. What worked for me was running yarn cache clean and doing a reinstall of all dependencies. Hope this helps someone.