Error building Gatsby site on Netlify (heifsave: Unsupported compression)

Hello! I am running into the following error when trying to deploy even a very basic Gatsby website, but it builds locally. Any help would be appreciated!

I10:47:32 AM: error error converting image Processing /opt/build/repo/src/images/example.png failed
10:47:32 AM: Original error:
10:47:32 AM: Failed to write /opt/build/repo/src/images/example.png into /opt/build/repo/public/static/705185e5354a42a4570368356f29b7e5/e515b/example.avif. (heifsave: Unsupported compression)
10:47:32 AM:
10:47:32 AM:
10:47:32 AM: SharpError: Processing /opt/build/repo/src/images/example.png failed
10:47:32 AM: Original error:
10:47:32 AM: Failed to write /opt/build/repo/src/images/example.png into /opt/build/repo/pu blic/static/705185e5354a42a4570368356f29b7e5/e515b/example.avif. (heifsave: Un supported compression)
10:47:32 AM:
10:47:32 AM: - process-file.js:118
10:47:32 AM: [repo]/[gatsby-plugin-sharp]/process-file.js:118:13
10:47:32 AM:
10:47:32 AM: - async Promise.all
10:47:32 AM:
10:47:32 AM:
10:47:32 AM: not finished Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 0.608s
10:47:32 AM: not finished onPostBootstrap - 0.124s
10:47:32 AM: not finished Build manifest and related icons - 0.123s
10:47:33 AM: ​
10:47:33 AM: β€œbuild.command” failed
10:47:33 AM: ────────────────────────────────────────────────────────────────
10:47:33 AM: ​
10:47:33 AM: Error message
10:47:33 AM: Command failed with exit code 1: npm run build
10:47:33 AM: ​
10:47:33 AM: Error location
10:47:33 AM: In Build command from Netlify app:
10:47:33 AM: npm run build
10:47:33 AM: ​
10:47:33 AM: Resolved config
10:47:33 AM: build:
10:47:33 AM: command: npm run build
10:47:33 AM: commandOrigin: ui
10:47:33 AM: publish: /opt/build/repo/public
10:47:33 AM: publishOrigin: ui
10:47:33 AM: plugins:
10:47:33 AM: - inputs: {}
10:47:33 AM: origin: ui
10:47:33 AM: package: β€˜@netlify/plugin-gatsby’
10:47:34 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:47:35 AM: Failing build: Failed to build site
10:47:35 AM: Finished processing build request in 1m5.592s

@tekd Try googling for heifsave: Un supported compression and read the kinds of results that appear:

Use the old ubuntu 20, their latest ubuntu 24 with the new libvips causing this error. I hope this helps as I learned it the hard way. Not sure how to to raise this concern to netlify though.

1 Like

That did it–thank you so much!

1 Like

@hrishikesh What’s the anticipated long term solution for these users?

Looks like it was already reported to Sharp Issue rendering AVIF files on Ubuntu 24.04 + libvips-dev 8.15.1 Β· Issue #4274 Β· lovell/sharp and that’s supposedly fixed in the latest versions.

Hi I’m having what looks like this same issue but on Ubuntu Focal 20.04. Any suggestions?

7:47:30 PM: Netlify Build                                                 
7:47:30 PM: ────────────────────────────────────────────────────────────────
7:47:30 PM: ​
7:47:30 PM: ❯ Version
7:47:30 PM:   @netlify/build 33.4.6
7:47:30 PM: ​
7:47:30 PM: ❯ Flags
7:47:30 PM:   accountId: 621912beeea8d52cb3fc9cde
7:47:30 PM:   baseRelDir: true
7:47:30 PM:   buildId: 6859e770988c040008f76788
7:47:30 PM:   deployId: 6859e770988c040008f7678a
7:47:30 PM: ​
7:47:30 PM: ❯ Current directory
7:47:30 PM:   /opt/build/repo
7:47:30 PM: ​
7:47:30 PM: ❯ Config file
7:47:30 PM:   No config file was defined: using default values.
7:47:30 PM: ​
7:47:30 PM: ❯ Context
7:47:30 PM:   deploy-preview
7:47:30 PM: ​
7:47:30 PM: Build command from Netlify app                                
7:47:30 PM: ────────────────────────────────────────────────────────────────
7:47:30 PM: ​
7:47:30 PM: $ npm run build
7:47:30 PM: > [email protected] build
7:47:30 PM: > gulp build & npx @11ty/eleventy --config=eleventy.js
7:47:31 PM: [23:47:31] Using gulpfile /opt/build/repo/gulpfile.js
7:47:31 PM: [23:47:31] Starting 'build'...
7:47:31 PM: [23:47:31] Starting 'clean'...
7:47:31 PM: [23:47:31] Finished 'clean' after 6.21 ms
7:47:31 PM: [23:47:31] Starting 'scss'...
7:47:31 PM: [23:47:31] Starting 'copy'...
7:47:31 PM: [23:47:31] Finished 'scss' after 150 ms
7:47:31 PM: [23:47:31] Finished 'copy' after 159 ms
7:47:31 PM: [23:47:31] Finished 'build' after 168 ms
7:47:31 PM: [11ty] Unhandled rejection in promise: (more in DEBUG output)
7:47:31 PM: [11ty] > heifsave: Unsupported compression
7:47:31 PM: heifsave: Unsupported compression
7:47:31 PM: `Error` was thrown:
7:47:31 PM: [11ty]     Error: heifsave: Unsupported compression
7:47:31 PM:     heifsave: Unsupported compression
7:47:31 PM: [11ty] Unhandled rejection in promise: (more in DEBUG output)
7:47:31 PM: [11ty] > heifsave: Unsupported compression
7:47:31 PM: heifsave: Unsupported compression
7:47:31 PM: heifsave: Unsupported compression
7:47:31 PM: `Error` was thrown:
7:47:31 PM: [11ty]     Error: heifsave: Unsupported compression
7:47:31 PM:     heifsave: Unsupported compression
7:47:31 PM:     heifsave: Unsupported compression
7:47:31 PM: [11ty] Unhandled rejection in promise: (more in DEBUG output)
7:47:31 PM: [11ty] > heifsave: Unsupported compression
7:47:31 PM: heifsave: Unsupported compression
7:47:31 PM: `Error` was thrown:
7:47:31 PM: [11ty]     Error: heifsave: Unsupported compression
7:47:31 PM:     heifsave: Unsupported compression
7:47:31 PM: [11ty] Problem writing Eleventy templates: (more in DEBUG output)
7:47:31 PM: [11ty] > Having trouble rendering njk template ./src/templates/index.njk
7:47:31 PM: `TemplateContentRenderError` was thrown
7:47:31 PM: [11ty] > (./src/templates/index.njk)
7:47:31 PM:   EleventyShortcodeError: Error with Nunjucks shortcode `image`
7:47:31 PM: `Template render error` was thrown
7:47:31 PM: [11ty] > heifsave: Unsupported compression
7:47:31 PM: heifsave: Unsupported compression
7:47:31 PM: `Template render error` was thrown:
7:47:31 PM: [11ty]     Error: heifsave: Unsupported compression
7:47:31 PM:     heifsave: Unsupported compression
7:47:31 PM: [11ty] Wrote 0 files in 0.17 seconds (v1.0.0)
7:47:31 PM: [11ty] A promise rejection was handled asynchronously: (more in DEBUG output)
7:47:31 PM: [11ty] > (No error message 

@tropicalnerd If using a newer version of sharp doesn’t work, then try downgrading the build image:

@nathanmartin I had the Ubuntu 20, but I was using an old version of eleventy-img which must have been using an outdated version sharp. Updating all my packages fixes it. Thanks for your help!

@tropicalnerd Sorry I’d missed your mention of that, glad you were able to get it sorted.