Astro build failed with git LFS enabled

Site name

patatrack.netlify.app

Hi, I’ve configured git-lfs to use in the site and was working fine but today I added a few changes and I got this error:

4:19:14 PM:  optimizing 15 images in batches of 32 
4:19:15 PM:  error   Input buffer contains unsupported image format
4:19:15 PM: Error: Input buffer contains unsupported image format
4:19:17 PM: ​
4:19:17 PM:   "build.command" failed                                        
4:19:17 PM: ────────────────────────────────────────────────────────────────

Is there a way to overcome this problem? I think is related to image optimization made by astro during build phase

Build Log:

4:17:43 PM: build-image version: 6c82004ef0368b3a0232c6837cead23188bb347e (focal)
4:17:43 PM: buildbot version: 0dfbdb6e6e614fd26450cfc6bacb47c4c6fd9626
4:17:43 PM: Building without cache
4:17:43 PM: Starting to prepare the repo for build
4:17:43 PM: Netlify Large Media is enabled, running git commands with GIT_LFS_SKIP_SMUDGE=1
4:17:43 PM: No cached dependencies found. Cloning fresh repo
4:17:43 PM: git clone --filter=blob:none https://github.com/tomashco/patatrack-cc
4:17:43 PM: Preparing Git Reference refs/heads/main
4:17:44 PM: Parsing package.json dependencies
4:17:45 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'astro build' in the Netlify UI
4:17:45 PM: Starting to install dependencies
4:17:45 PM: Started restoring cached go cache
4:17:45 PM: Finished restoring cached go cache
4:17:45 PM: Installing Go version 1.19.5 (requested 1.19.5)
4:17:50 PM: go version go1.19.5 linux/amd64
4:17:50 PM: Using PHP version 8.0
4:17:50 PM: v16.20.0 is already installed.
4:17:51 PM: Now using node v16.20.0 (npm v8.19.4)
4:17:51 PM: Enabling Node.js Corepack
4:17:51 PM: Started restoring cached build plugins
4:17:51 PM: Finished restoring cached build plugins
4:17:51 PM: Started restoring cached corepack dependencies
4:17:51 PM: Finished restoring cached corepack dependencies
4:17:51 PM: No npm workspaces detected
4:17:51 PM: Started restoring cached node modules
4:17:51 PM: Finished restoring cached node modules
4:17:51 PM: Installing npm packages using npm version 8.19.4
4:18:16 PM: npm WARN ERESOLVE overriding peer dependency
4:18:30 PM: npm WARN ERESOLVE overriding peer dependency
4:18:30 PM: npm WARN While resolving: ajv-keywords@5.1.0
4:18:30 PM: npm WARN Found: ajv@8.1.0
4:18:30 PM: npm WARN node_modules/netlify-cms-core/node_modules/ajv
4:18:30 PM: npm WARN   ajv@"8.1.0" from netlify-cms-core@2.55.2
4:18:30 PM: npm WARN   node_modules/netlify-cms-core
4:18:30 PM: npm WARN     netlify-cms-core@"^2.55.2" from netlify-cms-app@2.15.72
4:18:30 PM: npm WARN     node_modules/netlify-cms-app
4:18:30 PM: npm WARN   1 more (ajv-errors)
4:18:30 PM: npm WARN
4:18:30 PM: npm WARN Could not resolve dependency:
4:18:30 PM: npm WARN peer ajv@"^8.8.2" from ajv-keywords@5.1.0
4:18:30 PM: npm WARN node_modules/netlify-cms-core/node_modules/ajv-keywords
4:18:30 PM: npm WARN   ajv-keywords@"^5.0.0" from netlify-cms-core@2.55.2
4:18:30 PM: npm WARN   node_modules/netlify-cms-core
4:18:30 PM: npm WARN
4:18:30 PM: npm WARN Conflicting peer dependency: ajv@8.12.0
4:18:30 PM: npm WARN node_modules/ajv
4:18:30 PM: npm WARN   peer ajv@"^8.8.2" from ajv-keywords@5.1.0
4:18:30 PM: npm WARN   node_modules/netlify-cms-core/node_modules/ajv-keywords
4:18:30 PM: npm WARN     ajv-keywords@"^5.0.0" from netlify-cms-core@2.55.2
4:18:30 PM: npm WARN     node_modules/netlify-cms-core
4:18:33 PM: npm WARN deprecated trim@0.0.1: Use String.prototype.trim() instead
4:18:33 PM: npm WARN deprecated @types/vfile-message@2.0.0: This is a stub types definition. vfile-message provides its own type definitions, so you do not need this installed.
4:18:33 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
4:18:34 PM: npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
4:18:35 PM: npm WARN deprecated @hapi/address@4.1.0: Moved to 'npm install @sideway/address'
4:18:35 PM: npm WARN deprecated redux-devtools-extension@2.13.9: Package moved to @redux-devtools/extension.
4:18:35 PM: npm WARN deprecated @hapi/formula@2.0.0: Moved to 'npm install @sideway/formula'
4:18:36 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
4:18:37 PM: npm WARN deprecated @hapi/joi@17.1.1: Switch to 'npm install joi'
4:18:48 PM: added 1394 packages, and audited 1395 packages in 56s
4:18:48 PM: 402 packages are looking for funding
4:18:48 PM:   run `npm fund` for details
4:18:48 PM: 7 high severity vulnerabilities
4:18:48 PM: To address issues that do not require attention, run:
4:18:48 PM:   npm audit fix
4:18:48 PM: To address all issues (including breaking changes), run:
4:18:48 PM:   npm audit fix --force
4:18:48 PM: Run `npm audit` for details.
4:18:48 PM: npm packages installed
4:18:48 PM: Python version set to 3.8
4:18:48 PM: Attempting Ruby version 2.7.2, read from environment
4:18:49 PM: Using Ruby version 2.7.2
4:18:50 PM: Install dependencies script success
4:18:50 PM: Starting build script
4:18:50 PM: Using stage install dependencies
4:18:51 PM: Detected 1 framework(s)
4:18:51 PM: "astro" at version "2.1.9"
4:18:51 PM: Section completed: initializing
4:18:52 PM: ​
4:18:52 PM:   Netlify Build                                                 
4:18:52 PM: ────────────────────────────────────────────────────────────────
4:18:52 PM: ​
4:18:52 PM: ❯ Version
4:18:52 PM:   @netlify/build 29.9.0
4:18:52 PM: ​
4:18:52 PM: ❯ Flags
4:18:52 PM:   baseRelDir: true
4:18:52 PM:   buildId: 64298e7ed8ba4214af0a5c43
4:18:52 PM:   deployId: 64298e7ed8ba4214af0a5c45
4:18:52 PM: ​
4:18:52 PM: ❯ Current directory
4:18:52 PM:   /opt/build/repo
4:18:52 PM: ​
4:18:52 PM: ❯ Config file
4:18:52 PM:   /opt/build/repo/netlify.toml
4:18:52 PM: ​
4:18:52 PM: ❯ Context
4:18:52 PM:   production
4:18:52 PM: ​
4:18:52 PM:   1. build.command from netlify.toml                            
4:18:52 PM: ────────────────────────────────────────────────────────────────
4:18:52 PM: ​
4:18:52 PM: $ npm run build
4:18:52 PM: > patatrack.cc@0.9.8 build
4:18:52 PM: > astro build
4:18:55 PM: 02:18:55 PM [content] Types generated 384ms
4:18:55 PM: 02:18:55 PM [build] output target: static
4:18:55 PM: 02:18:55 PM [build] Collecting build info...
4:18:55 PM: 02:18:55 PM [build] Completed in 0.82s.
4:18:55 PM: 02:18:55 PM [build] Building static entrypoints...
4:18:58 PM: 02:18:58 PM [build] Completed in 3.59s.
4:18:58 PM: 
4:18:58 PM:  building client 
4:19:04 PM: Use of eval in "node_modules/netlify-cms-app/dist/netlify-cms-app.js" is strongly discouraged as it poses security risks and may cause issues with minification.
4:19:04 PM: Use of eval in "node_modules/netlify-cms-app/dist/netlify-cms-app.js" is strongly discouraged as it poses security risks and may cause issues with minification.
4:19:04 PM: Use of eval in "node_modules/netlify-cms-app/dist/netlify-cms-app.js" is strongly discouraged as it poses security risks and may cause issues with minification.
4:19:04 PM: Use of eval in "node_modules/netlify-cms-app/dist/netlify-cms-app.js" is strongly discouraged as it poses security risks and may cause issues with minification.
4:19:11 PM: 
4:19:11 PM: (!) Some chunks are larger than 500 kBs after minification. Consider:
4:19:11 PM: - Using dynamic import() to code-split the application
4:19:11 PM: - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
4:19:11 PM: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
4:19:11 PM: Completed in 12.57s.
4:19:11 PM: 
4:19:11 PM: 
4:19:11 PM:  generating static routes 
4:19:11 PM: ▶ node_modules/astro-netlify-cms/admin-dashboard.astro
4:19:11 PM:   └─ /admin/index.html (+7ms)
4:19:11 PM: ▶ src/pages/index.astro
4:19:12 PM:   └─ /index.html (+1.04s)
4:19:12 PM: ▶ src/pages/landing/mobile-app.astro
4:19:12 PM:   └─ /landing/mobile-app/index.html (+32ms)
4:19:12 PM: ▶ src/pages/landing/old-index.astro
4:19:13 PM:   └─ /landing/old-index/index.html (+475ms)
4:19:13 PM: ▶ src/pages/landing/startup.astro
4:19:13 PM:   └─ /landing/startup/index.html (+43ms)
4:19:13 PM: ▶ src/pages/landing/saas.astro
4:19:13 PM:   └─ /landing/saas/index.html (+55ms)
4:19:13 PM: ▶ src/pages/privacy.md
4:19:13 PM:   └─ /privacy/index.html (+27ms)
4:19:13 PM: λ src/pages/rss.xml.ts
4:19:13 PM:   └─ /rss.xml (+7ms)
4:19:13 PM: ▶ src/pages/terms.md
4:19:13 PM:   └─ /terms/index.html (+29ms)
4:19:13 PM: ▶ src/pages/404.astro
4:19:13 PM:   └─ /404.html (+4ms)
4:19:13 PM: ▶ src/pages/[...blog]/[category]/[...page].astro
4:19:13 PM:   └─ /category/tutorials/index.html (+121ms)
4:19:13 PM: ▶ src/pages/[...blog]/[tag]/[...page].astro
4:19:13 PM:   ├─ /tag/term_1/index.html (+39ms)
4:19:13 PM:   ├─ /tag/term_2/index.html (+76ms)
4:19:13 PM:   ├─ /tag/gravel/index.html (+119ms)
4:19:13 PM:   ├─ /tag/myself/index.html (+156ms)
4:19:13 PM:   ├─ /tag/profile/index.html (+193ms)
4:19:13 PM:   ├─ /tag/aboutmyself/index.html (+219ms)
4:19:13 PM:   ├─ /tag/astro/index.html (+253ms)
4:19:13 PM:   ├─ /tag/hello/index.html (+274ms)
4:19:13 PM:   ├─ /tag/riding/index.html (+295ms)
4:19:13 PM:   ├─ /tag/chilling/index.html (+318ms)
4:19:13 PM:   ├─ /tag/gpx/index.html (+339ms)
4:19:13 PM:   ├─ /tag/tailwind-css/index.html (+365ms)
4:19:13 PM:   ├─ /tag/front-end/index.html (+387ms)
4:19:13 PM:   ├─ /tag/tools/index.html (+408ms)
4:19:13 PM:   ├─ /tag/resources/index.html (+429ms)
4:19:13 PM:   └─ /tag/theme/index.html (+449ms)
4:19:13 PM: ▶ src/pages/[...blog]/[...page].astro
4:19:14 PM:   ├─ /blog/index.html (+141ms)
4:19:14 PM:   ├─ /blog/2/index.html (+188ms)
4:19:14 PM:   └─ /blog/3/index.html (+229ms)
4:19:14 PM: ▶ src/pages/[...blog]/index.astro
4:19:14 PM:   ├─ /this-is-a-new-mdx-post/index.html (+396ms)
4:19:14 PM:   ├─ /this-is-a-change-im-doing/index.html (+438ms)
4:19:14 PM:   ├─ /new-post-from-ilaria/index.html (+482ms)
4:19:14 PM:   ├─ /this-is-a-new-post-asdfasdf/index.html (+520ms)
4:19:14 PM:   ├─ /this-is-a-new-post/index.html (+561ms)
4:19:14 PM:   ├─ /this-is-my-very-first-blog-post/index.html (+600ms)
4:19:14 PM:   ├─ /this-is-a-title/index.html (+639ms)
4:19:14 PM:   ├─ /get-started-website-with-astro-tailwind-css/index.html (+676ms)
4:19:14 PM:   ├─ /useful-resources-to-create-websites/index.html (+703ms)
4:19:14 PM:   ├─ /astrowind-template-in-depth/index.html (+728ms)
4:19:14 PM:   └─ /how-to-customize-astrowind-to-your-brand/index.html (+0.75s)
4:19:14 PM:  optimizing 15 images in batches of 32 
4:19:15 PM:  error   Input buffer contains unsupported image format
4:19:15 PM: Error: Input buffer contains unsupported image format
4:19:17 PM: ​
4:19:17 PM:   "build.command" failed                                        
4:19:17 PM: ────────────────────────────────────────────────────────────────
4:19:17 PM: ​
4:19:17 PM:   Error message
4:19:17 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
4:19:17 PM: ​
4:19:17 PM:   Error location
4:19:17 PM:   In build.command from netlify.toml:
4:19:17 PM:   npm run build
4:19:17 PM: ​
4:19:17 PM:   Resolved config
4:19:17 PM:   build:
4:19:17 PM:     command: npm run build
4:19:17 PM:     commandOrigin: config
4:19:17 PM:     environment:
4:19:17 PM:       - NETLIFY_LFS_ORIGIN_URL
4:19:17 PM:     publish: /opt/build/repo/dist
4:19:17 PM:     publishOrigin: config
4:19:17 PM:   headers:
4:19:17 PM:     - for: /assets/*      values:        Cache-Control: public, max-age=31536000, immutable  headersOrigin: configCaching artifacts
4:19:17 PM: Started saving node modules
4:19:17 PM: Finished saving node modules
4:19:17 PM: Started saving build plugins
4:19:17 PM: Finished saving build plugins
4:19:17 PM: Started saving corepack cache
4:19:17 PM: Finished saving corepack cache
4:19:17 PM: Started saving pip cache
4:19:17 PM: Finished saving pip cache
4:19:17 PM: Started saving emacs cask dependencies
4:19:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:19:17 PM: Finished saving emacs cask dependencies
4:19:17 PM: Started saving maven dependencies
4:19:17 PM: Finished saving maven dependencies
4:19:17 PM: Started saving boot dependencies
4:19:17 PM: Finished saving boot dependencies
4:19:17 PM: Started saving rust rustup cache
4:19:17 PM: Finished saving rust rustup cache
4:19:17 PM: Started saving go dependencies
4:19:17 PM: Finished saving go dependencies
4:19:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:19:18 PM: Failing build: Failed to build site
4:19:18 PM: Finished processing build request in 1m35.222s

Hi @tomashco, welcome to the Netlify support forums. Can you share a bit about how you’ve set up Git LFS? Are you using Netlify Large Media (which currently supports png and jpg)? Does your site build locally?

Hi @tomrutgers , yes definitely.
I configured Netlify Large Media as described into the docs, configuring the git-lfs locally and adding a rule for all the public folder into .gitattributes. The repo I’m currently working on is:

The site build correctly on localhost. Today I decided to deploy the local changes and I found the pipeline was breaking as in the log I posted before. I think the problem is related to Astro that during the build phase does an optimisation on the the images.

I think I’m facing the same error of this other issue:

But maybe there are some possibilities or alternatives? I currently removed all the images inserted on git-lfs and removed the rule from .gitattributes and i’ve been able to finish the build phase and deploy on netlify, but I still have the problem of serving multiple images on the site (for which netlify Large Media would have been really helpful)

I’m pretty sure you’ll have to set up .gitattributes rules for NLM to work, I’d start with something generic (see below)

*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text

Hi @tomrutgers ,
I did a test now, adding this rule to gitAttributes:

public/campinglfs.png filter=lfs diff=lfs merge=lfs -text

I made it narrow to only one file because I just wanted to test it.

I receive this error during build phase:
11:31:13 AM: optimizing 14 images in batches of 32 11:31:13 AM: error Input buffer contains unsupported image format 11:31:13 AM: Error: Input buffer contains unsupported image format 11:31:14 AM: ​ 11:31:14 AM: "build.command" failed 11:31:14 AM: ────────────────────────────────────────────────────────────────

So what happens is that if I use an image that is under git-lfs the build breaks. If I don’t use that image the build works.

Hope it may help!
thank you

Thanks for sharing with the community @tomashco