Build failed after setting up Netlify Large Media with Git LFS, prompted Image Corrupted

Site name: purelearning.netlify.app

5:15:45 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
5:15:18 AM: build-image version: ad28fb91fae632ef7f2e4d659a892d68ee2681a6 (focal)
5:15:18 AM: buildbot version: 751c8de2ba48c52549712392ca0244c53d39c3c1
5:15:18 AM: Fetching cached dependencies
5:15:18 AM: Starting to download cache of 244.8MB
5:15:20 AM: Finished downloading cache in 2.225s
5:15:20 AM: Starting to extract cache
5:15:26 AM: Finished extracting cache in 5.481s
5:15:26 AM: Finished fetching cache in 7.754s
5:15:26 AM: Starting to prepare the repo for build
5:15:26 AM: Netlify Large Media is enabled, running git commands with GIT_LFS_SKIP_SMUDGE=1
5:15:26 AM: Preparing Git Reference refs/heads/main
5:15:29 AM: Starting to install dependencies
5:15:29 AM: Python version set to 3.8
5:15:29 AM: Attempting Ruby version 2.7.2, read from environment
5:15:29 AM: Using Ruby version 2.7.2
5:15:30 AM: Started restoring cached go cache
5:15:30 AM: Finished restoring cached go cache
5:15:30 AM: go version go1.19.11 linux/amd64
5:15:30 AM: Using PHP version 8.0
5:15:31 AM: Started restoring cached Node.js version
5:15:33 AM: Finished restoring cached Node.js version
5:15:33 AM: v18.17.0 is already installed.
5:15:34 AM: Now using node v18.17.0 (npm v9.6.7)
5:15:34 AM: Enabling Node.js Corepack
5:15:34 AM: Started restoring cached build plugins
5:15:34 AM: Finished restoring cached build plugins
5:15:34 AM: Started restoring cached corepack dependencies
5:15:34 AM: Finished restoring cached corepack dependencies
5:15:34 AM: No npm workspaces detected
5:15:34 AM: Started restoring cached node modules
5:15:34 AM: Finished restoring cached node modules
5:15:34 AM: Installing npm packages using npm version 9.6.7
5:15:35 AM: up to date, audited 356 packages in 727ms
5:15:35 AM: 129 packages are looking for funding
5:15:35 AM: run npm fund for details
5:15:35 AM: 1 moderate severity vulnerability
5:15:35 AM: To address all issues, run:
5:15:35 AM: npm audit fix
5:15:35 AM: Run npm audit for details.
5:15:35 AM: npm packages installed
5:15:35 AM: Install dependencies script success
5:15:35 AM: Starting build script
5:15:36 AM: Detected 1 framework(s)
5:15:36 AM: next at version 13.4.7
5:15:36 AM: Section completed: initializing
5:15:37 AM: ​
5:15:37 AM: Netlify Build
5:15:37 AM: ────────────────────────────────────────────────────────────────
5:15:37 AM: ​
5:15:37 AM: ❯ Version
5:15:37 AM: @netlify/build 29.17.1
5:15:37 AM: ​
5:15:37 AM: ❯ Flags
5:15:37 AM: baseRelDir: true
5:15:37 AM: buildId: 64bc46e3b66de10008efd262
5:15:37 AM: deployId: 64bc46e3b66de10008efd264
5:15:37 AM: ​
5:15:37 AM: ❯ Current directory
5:15:37 AM: /opt/build/repo
5:15:37 AM: ​
5:15:37 AM: ❯ Config file
5:15:37 AM: No config file was defined: using default values.
5:15:37 AM: ​
5:15:37 AM: ❯ Context
5:15:37 AM: production
5:15:38 AM: ​
5:15:38 AM: ❯ Using Next.js Runtime - v4.39.1
5:15:39 AM: ​
5:15:39 AM: @netlify/plugin-nextjs (onPreBuild event)
5:15:39 AM: ────────────────────────────────────────────────────────────────
5:15:39 AM: ​
5:15:39 AM: Next.js cache restored.
5:15:39 AM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
5:15:39 AM: ​
5:15:39 AM: (@netlify/plugin-nextjs onPreBuild completed in 110ms)
5:15:39 AM: ​
5:15:39 AM: Build command from Netlify app
5:15:39 AM: ────────────────────────────────────────────────────────────────
5:15:39 AM: ​
5:15:39 AM: $ npm run build
5:15:39 AM: > static-next-app@0.1.0 build
5:15:39 AM: > next build
5:15:39 AM: - info Creating an optimized production build…
5:15:44 AM: Failed to compile.
5:15:44 AM:
5:15:44 AM: next-flight-client-entry-loader?modules=%2Fopt%2Fbuild%2Frepo%2Fnode_modules%2Fnevery long text%2Ffont%2Fgoogle%2Ftarget.css%3F%7B%22path%22%3A%22app%2Flayout.tsx%22%2C%22import%22%3A%22Inter%22%2C%22arguments%22%3A%5B%7B%22subsets%22%3A%5B%22latin%22%5D%7D%5D%2C%22variableName%22%3A%22inter%22%7D&modules=%2Fopt%2Fbuild%2Frepo%2Fapp%2Fglobals.css&server=true!:1
5:15:44 AM: Error: Image import /opt/build/repo/assets/albums/2022_08_02__20_58_13_1.jpg is not a valid image file. The image may be corrupted or an unsupported format.
5:15:44 AM: …:1
5:15:44 AM: Error: Image import @/assets/albums/2022_08_02__20_58_13_1.jpg is not a valid image file. The image may be corrupted or an unsupported format.
5:15:44 AM: next-flight-client-entry-loader?modules=%2Fopt%2Fbuild%2Frepo%2Fnode_modules%2Fnext%2Fdist%2Fclient%2Flink.js&modules=%2Fopt%2Fbuild%2Fvery long text22Inter%22%2C%22arguments%22%3A%5B%7B%22subsets%22%3A%5B%22latin%22%5D%7D%5D%2C%22variableName%22%3A%22inter%22%7D&modules=%2Fopt%2Fbuild%2Frepo%2Fapp%2Fglobals.css&server=true!:2
5:15:44 AM: Error: Image import /opt/build/repo/assets/albums/2022_08_09__13_37_48.jpg is not a valid image file. The image may be corrupted or an unsupported format.
5:15:44 AM: …:2
5:15:44 AM: Error: Image import @/assets/albums/2022_08_09__13_37_48.jpg is not a valid image file. The image may be corrupted or an unsupported format.
5:15:44 AM: next-flight-client-entry-loader?modules=%2Fopt%2Fbuild%2Frepo%2Fnode_modules%2Fnext%2Fdist%2Fclient%2Flink.js&modules=%2Fopt%2Fbuild%2Frepo%2Fassets%2Falbums%2F2022_08_02__20_58_13_1.jpg&modules=%2Fopt%2Fbuild%2Frepo%2Fassets%2Falbums%2F2022_08_09__13_37_48.jpg&modules=%2Fopt%2Fbuild%2very long textath%22%3A%22app%2Flayout.tsx%22%2C%22import%22%3A%22Inter%22%2C%22arguments%22%3A%5B%7B%22subsets%22%3A%5B%22latin%22%5D%7D%5D%2C%22variableName%22%3A%22inter%22%7D&modules=%2Fopt%2Fbuild%2Frepo%2Fapp%2Fglobals.css&server=true!:3
5:15:44 AM: Error: Image import /opt/build/repo/assets/albums/2022_08_09__13_37_48_1.jpg is not a valid image file. The image may be corrupted or an unsupported format.
5:15:44 AM: > Build failed because of webpack errors
5:15:44 AM: ​
5:15:44 AM: build.command failed
5:15:44 AM: ────────────────────────────────────────────────────────────────
5:15:44 AM: ​
5:15:44 AM: Error message
5:15:44 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
5:15:44 AM: ​
5:15:44 AM: Error location
5:15:44 AM: In Build command from Netlify app:
5:15:44 AM: npm run build
5:15:44 AM: ​
5:15:44 AM: Resolved config
5:15:44 AM: build:
5:15:44 AM: command: npm run build
5:15:44 AM: commandOrigin: ui
5:15:44 AM: environment:
5:15:44 AM: - GIT_LFS_ENABLED
5:15:44 AM: - NETLIFY_LFS_ORIGIN_URL
5:15:44 AM: - NEXT_PRIVATE_TARGET
5:15:44 AM: publish: /opt/build/repo/.next
5:15:44 AM: publishOrigin: ui
5:15:44 AM: plugins:
5:15:44 AM: - inputs: {}
5:15:44 AM: origin: ui
5:15:44 AM: package: ‘@netlify/plugin-nextjs’
5:15:44 AM: Caching artifacts
5:15:44 AM: Started saving node modules
5:15:44 AM: Finished saving node modules
5:15:44 AM: Started saving build plugins
5:15:44 AM: Finished saving build plugins
5:15:44 AM: Started saving corepack cache
5:15:44 AM: Finished saving corepack cache
5:15:44 AM: Started saving pip cache
5:15:44 AM: Finished saving pip cache
5:15:44 AM: Started saving emacs cask dependencies
5:15:45 AM: Finished saving emacs cask dependencies
5:15:45 AM: Started saving maven dependencies
5:15:45 AM: Finished saving maven dependencies
5:15:45 AM: Started saving boot dependencies
5:15:45 AM: Finished saving boot dependencies
5:15:45 AM: Started saving rust rustup cache
5:15:45 AM: Finished saving rust rustup cache
5:15:45 AM: Started saving go dependencies
5:15:45 AM: Finished saving go dependencies
5:15:45 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:15:45 AM: Failing build: Failed to build site
5:15:45 AM: Finished processing build request in 27.348s

Steps taken:

  1. Tried netlify env:set GIT_LFS_ENABLED true but was prompted Failed during stage 'preparing repo': Conflict LFS setup, so I set it back to false
  2. Remove unused images in the assets folder and commit to Github
  3. Tried “Clear cache and retry with latest branch commit”, but prompted with the same error message

Note: None of the images used are more than 1Mb

So, I checked my Large Media, there weren’t any image files uploaded but my Git did started tracking my image files…

(https://github.com/poh5796/pure_nature_learning/blob/main/assets/albums/2022_08_02__20_58_13_1.jpg)

Maybe we can try removing Large Media? Please read the following and confirm:

If you have read that, please confirm you have backups of all files and that we should proceed with removing the Large Media add-on.

Hi, I have my files backed up locally and created a new topic in admin board as the Support Guide suggested.

Topic link: Remove the Large Media add-on for my site [ffd35194-b1af-4eb4-b6b9-7d9cc54e8872]

:wave: @poh5796
Large media has been removed on the site.

Hope that helps!