Gatsby build failing on netlify but works locally [Failed to retrieve metadata from image]

Hey guys,

After 3 days of debugging, I finally caved in and decided to ask for help.

I’m building a site with Gatsby and decided to give Netlify a shot but I’m running into a slight problem with deployment, specifically any image on my site will run into a “Failed to retrieve metadata from image” error.

Here’s one of my deployment build logs:
https://app.netlify.com/sites/musing-montalcini-e197b2/deploys/5ff60d5b1918fa00081814cc

At first I thought it was a problem with mdx not handling inline images correctly but after removing all images from mdx files, I still got the same error with another image :slightly_frowning_face:

Here are my build settings:
2021-01-06 21_00_23-Build & deploy _ Site settings
And here’s the repo:
https://github.com/ggolubic/portfolio-v2/tree/gg/fix-build

I’ve tried just about everything I’ve found including adding

  • "resolutions": { "sharp": "0.27.0" } to package.json
  • running npm audit fix
  • updating dependencies
  • checked for case sensitivity issues
  • triple checked gatsby-config.js to make sure all plugins are there

Here are my gatsby-config and package.json files
https://github.com/ggolubic/portfolio-v2/blob/gg/fix-build/gatsby-config.js
https://github.com/ggolubic/portfolio-v2/blob/gg/fix-build/package.json

Any help would be greatly appreciated :slight_smile:

Hey @ggolubic :wave:t2:

Welcome to The Community :netliheart:

Typically a site having a public repo means that the deploy logs are also publicly accessible (if you know the URL), but your build log is not. Could be the case if you connected the Netlify site to the repo when it was private (if it was) or other random reasons, but, could you post the failed log here in the thread please? :slight_smile:

Additionally (and unrelated), I’d like to strongly stress that you should not using gatsby clean in your build command. If that’s something you did as part of the debugging process — totally understand, but that’s not something you want to use for a production site.


Jon

Hey @jonsully , thanks for the swift reply!

I didn’t know that the logs would be private as well and the repo was indeed private before opening this thread :smiley: so posting the log here:

8:19:55 PM: Waiting for other deploys from your team to complete
8:21:19 PM: Build ready to start
8:21:21 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
8:21:21 PM: build-image tag: v3.6.0
8:21:21 PM: buildbot version: e26592b49d9d56b21349effe1b8fab4d50845f11
8:21:21 PM: Fetching cached dependencies
8:21:21 PM: Failed to fetch cache, continuing with build
8:21:21 PM: Starting to prepare the repo for build
8:21:21 PM: No cached dependencies found. Cloning fresh repo
8:21:21 PM: git clone https://github.com/ggolubic/portfolio-v2
8:21:23 PM: Preparing Git Reference pull/7/head
8:21:25 PM: Starting build script
8:21:25 PM: Installing dependencies
8:21:25 PM: Python version set to 2.7
8:21:26 PM: Downloading and installing node v12.16.1…
8:21:27 PM: Downloading https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
8:21:27 PM: Computing checksum with sha256sum
8:21:28 PM: Checksums matched!
8:21:30 PM: Now using node v12.16.1 (npm v6.13.4)
8:21:30 PM: Started restoring cached build plugins
8:21:30 PM: Finished restoring cached build plugins
8:21:31 PM: Attempting ruby version 2.7.1, read from environment
8:21:32 PM: Using ruby version 2.7.1
8:21:32 PM: Using PHP version 5.6
8:21:32 PM: Started restoring cached node modules
8:21:32 PM: Finished restoring cached node modules
8:21:33 PM: Installing NPM modules using NPM version 6.13.4
8:22:27 PM: > bufferutil@4.0.2 install /opt/build/repo/node_modules/bufferutil
8:22:27 PM: > node-gyp-build
8:22:27 PM: > utf-8-validate@5.0.3 install /opt/build/repo/node_modules/utf-8-validate
8:22:27 PM: > node-gyp-build
8:22:28 PM: > sharp@0.26.3 install /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp
8:22:28 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
8:22:29 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linux-x64.tar.br
8:22:31 PM: > sharp@0.25.4 install /opt/build/repo/node_modules/sharp
8:22:31 PM: > (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
8:22:32 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
8:22:35 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
8:22:35 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
8:22:35 PM: > core-js@3.7.0 postinstall /opt/build/repo/node_modules/core-js
8:22:35 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
8:22:35 PM: > core-js-pure@3.7.0 postinstall /opt/build/repo/node_modules/core-js-pure
8:22:35 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
8:22:36 PM: > gatsby-telemetry@1.4.0 postinstall /opt/build/repo/node_modules/gatsby-telemetry
8:22:36 PM: > node src/postinstall.js || true
8:22:36 PM: > gatsby-telemetry@1.7.1 postinstall /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/gatsby-telemetry
8:22:36 PM: > node src/postinstall.js || true
8:22:37 PM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
8:22:37 PM: > node lib/install.js
8:22:37 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
8:22:37 PM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
8:22:37 PM: > node lib/install.js
8:22:37 PM: :heavy_check_mark: pngquant pre-build test passed successfully
8:22:38 PM: > gatsby-cli@2.13.0 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
8:22:38 PM: > node scripts/postinstall.js
8:22:38 PM: > gatsby@2.26.0 postinstall /opt/build/repo/node_modules/gatsby
8:22:38 PM: > node scripts/postinstall.js
8:22:41 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
8:22:41 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:22:41 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/gatsby-page-utils/node_modules/fsevents):
8:22:41 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:22:41 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
8:22:41 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
8:22:41 PM: added 2623 packages from 1334 contributors and audited 2632 packages in 67.351s
8:22:43 PM: 197 packages are looking for funding
8:22:43 PM: run npm fund for details
8:22:43 PM: found 2 high severity vulnerabilities
8:22:43 PM: run npm audit fix to fix them, or npm audit for details
8:22:43 PM: NPM modules installed
8:22:44 PM: Started restoring cached go cache
8:22:44 PM: Finished restoring cached go cache
8:22:44 PM: go version go1.14.4 linux/amd64
8:22:44 PM: go version go1.14.4 linux/amd64
8:22:44 PM: Installing missing commands
8:22:44 PM: Verify run directory
8:22:45 PM: ​
8:22:45 PM: ────────────────────────────────────────────────────────────────
8:22:45 PM: Netlify Build
8:22:45 PM: ────────────────────────────────────────────────────────────────
8:22:45 PM: ​
8:22:45 PM: ❯ Version
8:22:45 PM: @netlify/build 8.0.1
8:22:45 PM: ​
8:22:45 PM: ❯ Flags
8:22:45 PM: deployId: 5ff60d5b1918fa00081814cc
8:22:45 PM: mode: buildbot
8:22:45 PM: ​
8:22:45 PM: ❯ Current directory
8:22:45 PM: /opt/build/repo
8:22:45 PM: ​
8:22:45 PM: ❯ Config file
8:22:45 PM: No config file was defined: using default values.
8:22:45 PM: ​
8:22:45 PM: ❯ Context
8:22:45 PM: deploy-preview
8:22:45 PM: ​
8:22:45 PM: ────────────────────────────────────────────────────────────────
8:22:45 PM: 1. Build command from Netlify app
8:22:45 PM: ────────────────────────────────────────────────────────────────
8:22:45 PM: ​
8:22:45 PM: $ gatsby clean && gatsby build
8:22:47 PM: info Deleting .cache, public, /opt/build/repo/node_modules/.cache/babel-loader, /opt/build/repo/node_modules/.cache/terser-webpack-plugin
8:22:47 PM: info Successfully deleted directories
8:22:49 PM: success open and validate gatsby-configs - 0.047s
8:22:51 PM: success load plugins - 1.348s
8:22:51 PM: success onPreInit - 0.035s
8:22:51 PM: success delete html and css files from previous builds - 0.003s
8:22:51 PM: success initialize cache - 0.006s
8:22:51 PM: success copy gatsby files - 0.028s
8:22:51 PM: success onPreBootstrap - 0.016s
8:22:51 PM: success createSchemaCustomization - 0.023s
8:22:52 PM: error Failed to retrieve metadata from image /opt/build/repo/src/data/work/Tequila/tequila.png
8:22:52 PM:
8:22:52 PM:
8:22:52 PM: Error: Input file contains unsupported image format
8:22:52 PM:
8:22:52 PM: not finished source and transform nodes - 0.999s
8:22:52 PM: ​
8:22:52 PM: ────────────────────────────────────────────────────────────────
8:22:52 PM: “build.command” failed
8:22:52 PM: ────────────────────────────────────────────────────────────────
8:22:52 PM: ​
8:22:52 PM: Error message
8:22:52 PM: Command failed with exit code 1: gatsby clean && gatsby build
8:22:52 PM: ​
8:22:52 PM: Error location
8:22:52 PM: In Build command from Netlify app:
8:22:52 PM: gatsby clean && gatsby build
8:22:52 PM: ​
8:22:52 PM: Resolved config
8:22:52 PM: build:
8:22:52 PM: command: gatsby clean && gatsby build
8:22:52 PM: commandOrigin: ui
8:22:52 PM: environment:
8:22:52 PM: - NODE_VERSION
8:22:52 PM: - REVIEW_ID
8:22:52 PM: publish: /opt/build/repo/public
8:22:52 PM: Caching artifacts
8:22:52 PM: Started saving node modules
8:22:52 PM: Finished saving node modules
8:22:52 PM: Started saving build plugins
8:22:52 PM: Finished saving build plugins
8:22:52 PM: Started saving pip cache
8:22:52 PM: Finished saving pip cache
8:22:52 PM: Started saving emacs cask dependencies
8:22:52 PM: Finished saving emacs cask dependencies
8:22:52 PM: Started saving maven dependencies
8:22:52 PM: Finished saving maven dependencies
8:22:52 PM: Started saving boot dependencies
8:22:52 PM: Finished saving boot dependencies
8:22:52 PM: Started saving rust rustup cache
8:22:52 PM: Finished saving rust rustup cache
8:22:52 PM: Started saving rust cargo bin cache
8:22:52 PM: Finished saving rust cargo bin cache
8:22:52 PM: Started saving go dependencies
8:22:52 PM: Finished saving go dependencies
8:22:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:22:56 PM: Failing build: Failed to build site
8:22:56 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
8:22:56 PM: Finished processing build request in 1m35.107920817s

Also here’s a newer one in case they become public once the repo is public :
https://app.netlify.com/sites/musing-montalcini-e197b2/deploys/5ff632f7b61d544dfccc10c8

It was one of the many things I tried whilst debugging but thanks for the advice!

Update:
After searching node modules for that specific error message I found it in gatsby-plugin-sharp and managed to solve it after removing all traces of Gatsby on my local machine and a full clean reinstall of modules/dependencies. It must’ve been some sort of clash in dependencies which led to the vague error message.

Anyway, glad to see that its not a problem with Netlify and hoping this will help someone in the future.