Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLib-CRITICAL — an issue with Sharp. #3570

Closed
piotrfonte opened this issue Jan 17, 2018 · 16 comments
Closed

GLib-CRITICAL — an issue with Sharp. #3570

piotrfonte opened this issue Jan 17, 2018 · 16 comments

Comments

@piotrfonte
Copy link
Contributor

Description

Not sure when that happened, wasn’t running my site for a while, changed nothing in the repo, and now gatsby develop fails at the following. Could mean has to do something with OS upgrade?

…

vips warning: VipsJpeg: error reading resolution
error Cannot read property 'parent' of undefined
TypeError: Cannot read property 'parent' of undefined

[…]

  - util.js:16 Object.tryCatcher
    [piotrf]/[bluebird]/js/release/util.js:16:23
 
error UNHANDLED REJECTION

  TypeError: Cannot read property 'parent' of undefined
  
  - parse.js:69 Function.exports.update
    [piotrf]/[cheerio]/lib/parse.js:69:26

[…]

(sharp:11672): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:11672): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed

(sharp:11672): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
Segmentation fault: 11

Environment

Gatsby version: 1.9.157
Gatsby-cli version: 1.1.28
Node.js version: v9.4.0
Operating System: MacOS High Sierra 10.13.2

File contents (if changed):

package.json:

  "dependencies": {
    "gatsby": "^1.9.157",
    "gatsby-cli": "^1.1.28",
    "gatsby-image": "^1.0.33",
    "gatsby-link": "^1.6.34",
    "gatsby-plugin-catch-links": "^1.0.14",
    "gatsby-plugin-google-analytics": "^1.0.15",
    "gatsby-plugin-netlify": "^1.0.14",
    "gatsby-plugin-react-helmet": "^2.0.3",
    "gatsby-plugin-react-next": "^1.0.7",
    "gatsby-plugin-sharp": "^1.6.25",
    "gatsby-plugin-sitemap": "^1.2.10",
    "gatsby-plugin-styled-components": "^2.0.4",
    "gatsby-remark-autolink-headers": "^1.4.11",
    "gatsby-remark-copy-linked-files": "^1.5.25",
    "gatsby-remark-external-links": "^0.0.4",
    "gatsby-remark-images": "^1.5.37",
    "gatsby-source-filesystem": "^1.5.11",
    "gatsby-transformer-remark": "^1.7.28",
    "gatsby-transformer-sharp": "^1.6.16",
    "polished": "^1.9.0",
    "react-helmet": "^5.2.0",
    "styled-components": "^2.4.0"
  },
  "devDependencies": {
    "eslint": "4.15.0",
    "eslint-config-airbnb": "16.1.0",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.5.1",
    "prettier": "^1.10.2"
  },

Anyone else experiencing this?

@KyleAMathews
Copy link
Contributor

I'm guessing yeah, something to do with the native dependency. Did you try removing node_modules and reinstalling?

@piotrfonte
Copy link
Contributor Author

Yes, I did. No luck. I also tried rolling back gatsby and sharp a few versions, no luck.

@ghost
Copy link

ghost commented Jan 18, 2018

I had exactly the same issues yesterday! But I can't exactly tell how I've solved it?

It did appear after installing a new react component react-cookie-banner. Delete node_modules and .cache didn't help me. Then I removed the package and changes and gatsby worked again. I reinstalled react-cookie-banner and ....its worked! -Very, very scary! :)

@piotrfonte
Copy link
Contributor Author

Hm. This sucks balls. I’ve been unable to work on my site ever since the issue surfaced. I had not added nor removed any packages.

@KyleAMathews
Copy link
Contributor

@PiotrF very weird :-(

Any chance you have another machine you could try running this site on?

@piotrfonte
Copy link
Contributor Author

Weird indeed. Yes I have tried that. Build was also failing on netlify, weirdly. I have now updated the following dependencies and the issue is gone.

 styled-components  ^2.4.0  →  ^3.0.2 
 eslint             4.15.0  →  4.16.0 
 gatsby                     ^1.9.159  →  ^1.9.165 
 gatsby-image                ^1.0.33  →   ^1.0.34 
 gatsby-remark-images        ^1.5.37  →   ^1.5.39 
 gatsby-source-filesystem    ^1.5.11  →   ^1.5.14 
 gatsby-transformer-remark   ^1.7.28  →   ^1.7.29 

…so closing this one for now.

@discordianfish
Copy link

I'm having the same problem after creating a new blog-starter project and adding my existing pages.

@fk fk added the API/Plugins label Jan 25, 2018
@lourd
Copy link
Contributor

lourd commented Feb 6, 2018

I just ran across this problem as well.

My path started when doing my first deployment to Netlify of a site that I've been working on locally for a few weeks. My first deploy failed due to an error building the sharp module. Here's the relevant output

error /opt/build/repo/node_modules/sharp: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /opt/build/repo/node_modules/sharp
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp http GET https://nodejs.org/download/release/v8.9.4/node-v8.9.4-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v8.9.4/node-v8.9.4-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v8.9.4/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v8.9.4/SHASUMS256.txt
gyp info spawn /opt/buildhome/python2.7/bin/python2
gyp info spawn args [ '/opt/buildhome/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/build/repo/node_modules/sharp/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/buildhome/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/buildhome/.node-gyp/8.9.4/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/opt/buildhome/.node-gyp/8.9.4',
gyp info spawn args   '-Dnode_gyp_dir=/opt/buildhome/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/opt/buildhome/.node-gyp/8.9.4/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/opt/build/repo/node_modules/sharp',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
module.js:540
    throw err;
    ^
Error: Cannot find module 'fstream'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/opt/build/repo/node_modules/tar/lib/entry.js:14:15)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
gyp: Call to 'GLOBAL_VIPS_VERSION="7.42.4" node -e "require('./binding').use_global_vips()"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/opt/buildhome/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.4.86+
gyp ERR! command "/opt/buildhome/.nvm/versions/node/v8.9.4/bin/node" "/opt/buildhome/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/build/repo/node_modules/sharp
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

First I tried upgrading all of my dependencies. Here's the relevant modules that got bumped:

  • gatsby from 1.9.151 to 1.9.183
  • gatsby-plugin-sharp from 1.6.24 to 1.6.27
  • gatsby-remark-copy-linked-files from 1.5.25 to 1.5.26
  • gatsby-remark-images from 1.5.36 to 1.5.41
  • gatsby-transformer-remark from 1.7.28 to 1.7.30
  • gatsby-transformer-sharp from 1.6.16 to 1.6.18
  • sharp from 0.17.3 to 0.19.0

On the next deployment I got a build error for cwebp-bin:

error /opt/build/repo/node_modules/cwebp-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /opt/build/repo/node_modules/cwebp-bin
Output:
module.js:540
    throw err;
    ^
Error: Cannot find module 'bl'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/opt/build/repo/node_modules/tar-stream/extract.js:2:10)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

Researching that error led me to #2076. I've been using yarn, my repo has a yarn.lock file. I got rid of it and let Netlify default to using npm. On the next deployment, the initial dependency installation succeeded, but the site build started failing.

error Cannot read property 'parent' of null

  TypeError: Cannot read property 'parent' of null
  
  - parse.js:69 Function.exports.update
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/parse.js:69:26
  
  - parse.js:19 module.exports
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/parse.js:19:11
  
  - static.js:27 Function.exports.load
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/static.js:27:14
  
  - index.js:169 
    [repo]/[gatsby-remark-copy-linked-files]/index.js:169:21
  
  - index.js:31 one
    [repo]/[unist-util-visit]/index.js:31:16
  
  - index.js:54 all
    [repo]/[unist-util-visit]/index.js:54:25
  
  - index.js:39 one
    [repo]/[unist-util-visit]/index.js:39:14
  
  - index.js:22 visit
    [repo]/[unist-util-visit]/index.js:22:3
  
  - index.js:168 module.exports
    [repo]/[gatsby-remark-copy-linked-files]/index.js:168:3
  
  - extend-node-type.js:150 
    [repo]/[gatsby-transformer-remark]/extend-node-type.js:150:32
  
  - util.js:16 tryCatcher
    [repo]/[bluebird]/js/release/util.js:16:23
  
  - reduce.js:155 Object.gotValue
    [repo]/[bluebird]/js/release/reduce.js:155:18
  
  - reduce.js:144 Object.gotAccum
    [repo]/[bluebird]/js/release/reduce.js:144:25
  
  - util.js:16 Object.tryCatcher
    [repo]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [repo]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [repo]/[bluebird]/js/release/promise.js:569:18
  

error UNHANDLED REJECTION

  TypeError: Cannot read property 'parent' of null
  
  - parse.js:69 Function.exports.update
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/parse.js:69:26
  
  - parse.js:19 module.exports
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/parse.js:19:11
  
  - static.js:27 Function.exports.load
    [repo]/[gatsby-remark-copy-linked-files]/[cheerio]/lib/static.js:27:14
  
  - index.js:169 
    [repo]/[gatsby-remark-copy-linked-files]/index.js:169:21
  
  - index.js:31 one
    [repo]/[unist-util-visit]/index.js:31:16
  
  - index.js:54 all
    [repo]/[unist-util-visit]/index.js:54:25
  
  - index.js:39 one
    [repo]/[unist-util-visit]/index.js:39:14
  
  - index.js:22 visit
    [repo]/[unist-util-visit]/index.js:22:3
  
  - index.js:168 module.exports
    [repo]/[gatsby-remark-copy-linked-files]/index.js:168:3
  
  - extend-node-type.js:150 
    [repo]/[gatsby-transformer-remark]/extend-node-type.js:150:32
  
  - util.js:16 tryCatcher
    [repo]/[bluebird]/js/release/util.js:16:23
  
  - reduce.js:155 Object.gotValue
    [repo]/[bluebird]/js/release/reduce.js:155:18
  
  - reduce.js:144 Object.gotAccum
    [repo]/[bluebird]/js/release/reduce.js:144:25
  
  - util.js:16 Object.tryCatcher
    [repo]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [repo]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [repo]/[bluebird]/js/release/promise.js:569:18
  

(sharp:1464): GLib-CRITICAL **: 17:52:15.015: g_hash_table_lookup: assertion 'hash_table != NULL' failed
(sharp:1464): GLib-CRITICAL **: 17:52:15.017: g_hash_table_lookup: assertion 'hash_table != NULL' failed
(sharp:1464): GLib-CRITICAL **: 17:52:15.018: g_hash_table_lookup: assertion 'hash_table != NULL' failed
(sharp:1464): GLib-CRITICAL **: 17:52:15.018: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
(sharp:1464): GLib-CRITICAL **: 17:52:15.018: g_hash_table_lookup: assertion 'hash_table != NULL' failed

I reproduced this behavior on my local machine by removing node_modules/ and .cache/ and installing with yarn vs npm. The build works fine after a yarn installation. It fails after an npm installation.

Environments:

  • OS: macOS 10.12.6 and Netlify's Debian docker container
  • Node.js: 8.9.0 and 8.9.4
  • Gatsby: 1.9.151 and 1.9.183
  • Sharp: 0.19.0
  • Yarn: 1.3.2
  • npm: 5.5.1 and 5.6.0

I'm stumped and extremely frustrated. I'm not familiar with debugging native dependency issues with Node. I just wanted to deploy my first draft so I could start getting feedback, and here I am 3 hours later 😖

@lourd
Copy link
Contributor

lourd commented Feb 6, 2018

I installed Docker, pulling Netlify's docker image, and following their instructions here for running a build locally. I ran into a separate issue with the script choking on yarn install, thinking this line was trying to add a dependency instead of installing all of the existing dependencies.

error install has been replaced with add to add new dependencies. Run "yarn add " instead.

I changed that line to just yarn install --verbose. The build worked fine without any error. No new clues.

Note, I've already tried several times redeploying on Netlify with a clear build cache

@lourd
Copy link
Contributor

lourd commented Feb 6, 2018

I found the root issue

@lourd
Copy link
Contributor

lourd commented Feb 6, 2018

Yarn has already fixed the problem in the latest version, 1.4, which is still in the release candidate stage. You can use it by specifying it in a netlify.toml file

[build.environment]
  YARN_VERSION = "1.4.0"

Classic software day... long rabbit hole, simple fix 😪

@AnalogMemory
Copy link
Contributor

I was able to fix this by just removing yarn.lock since it's an issue with Yarn
npm works fine

BradMcGonigle added a commit to BradMcGonigle/bradmcgonigle-web that referenced this issue Feb 16, 2018
@samanthaming
Copy link

Adding the YARN_VERSION = 1.4.0 to the Build environment variables worked for me. Thanks @lourd 👏 👏 👏

@kepi0809
Copy link

kepi0809 commented Feb 19, 2019

if it doesn't work with npm nor yarn the your issue is probably because of _tracedSVG
#8301 (note: title is misleading it's not because of the extension)
Just writing here because it could've spared couple of hours for me

EDIT

The problem was due to an image that had too long name, I only knew it because the plugin were updated since then and it actually a usable error message.

@jeffrafter
Copy link

This is closed but I wanted to add a note that I saw this yesterday. It was really hard to find why it was happening. Switching from npm to yarn made it work. But I wanted to dig deeper. It turns out that the problem was a bad link in my markdown (a bad closing ]. [Something](https://link.com] ). Fixing this fixed all of the images (not sure why). Just in case this helps someone down the road.

@xpzouying
Copy link

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

delete package-lock.json
use yarn
apt install libglu1 libxi-dev
It works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants