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

Netlify builds fail when changing images #11

Open
empoweragency opened this issue Jun 17, 2023 · 3 comments
Open

Netlify builds fail when changing images #11

empoweragency opened this issue Jun 17, 2023 · 3 comments

Comments

@empoweragency
Copy link

Describe the bug
If the home page image is changed, then the Netlify build fails. The biuld fails even if you switch back to the original image.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy to Netlify
  2. Login to Netlify CMS
  3. Navigate to Pages > Home
  4. Edit the home page image
  5. Upload a new image
  6. Save changes to trigger a Netlify build
  7. Build fails

Expected behavior
Expect the image to change and the build to pass

4:27:47 AM: Build ready to start
4:28:12 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:27:49 AM: build-image version: c11c0eb9939c949586b0f78302107908b668a11e (focal)
4:27:49 AM: buildbot version: c11c0eb9939c949586b0f78302107908b668a11e
4:27:49 AM: Fetching cached dependencies
4:27:49 AM: Starting to download cache of 273.1MB
4:27:53 AM: Finished downloading cache in 3.97s
4:27:53 AM: Starting to extract cache
4:27:55 AM: Finished extracting cache in 2.042s
4:27:55 AM: Finished fetching cache in 6.103s
4:27:55 AM: Starting to prepare the repo for build
4:27:55 AM: Preparing Git Reference refs/heads/master
4:27:57 AM: Starting to install dependencies
4:27:57 AM: Python version set to 3.8
4:27:57 AM: Attempting Ruby version 2.7.2, read from environment
4:27:58 AM: Using Ruby version 2.7.2
4:27:58 AM: Started restoring cached go cache
4:27:58 AM: Finished restoring cached go cache
4:27:58 AM: go version go1.19.10 linux/amd64
4:27:59 AM: Using PHP version 8.0
4:28:00 AM: Started restoring cached Node.js version
4:28:00 AM: Finished restoring cached Node.js version
4:28:00 AM: Attempting Node.js version '16' from .nvmrc
4:28:01 AM: v16.20.0 is already installed.
4:28:01 AM: Now using node v16.20.0 (npm v8.19.4)
4:28:01 AM: Enabling Node.js Corepack
4:28:01 AM: Started restoring cached build plugins
4:28:01 AM: Finished restoring cached build plugins
4:28:01 AM: Started restoring cached corepack dependencies
4:28:01 AM: Finished restoring cached corepack dependencies
4:28:01 AM: No npm workspaces detected
4:28:01 AM: Started restoring cached node modules
4:28:01 AM: Finished restoring cached node modules
4:28:01 AM: Installing npm packages using npm version 8.19.4
4:28:04 AM: up to date, audited 592 packages in 3s
4:28:04 AM: 105 packages are looking for funding
4:28:04 AM: run npm fund for details
4:28:04 AM: 5 vulnerabilities (2 moderate, 1 high, 2 critical)
4:28:04 AM: To address all issues (including breaking changes), run:
4:28:04 AM: npm audit fix --force
4:28:04 AM: Run npm audit for details.
4:28:04 AM: npm packages installed
4:28:05 AM: Install dependencies script success
4:28:05 AM: Starting build script
4:28:06 AM: Detected 1 framework(s)
4:28:06 AM: eleventy at version 0.11.1
4:28:06 AM: Section completed: initializing
4:28:07 AM: ​
4:28:07 AM: Netlify Build
4:28:07 AM: ────────────────────────────────────────────────────────────────
4:28:07 AM: ​
4:28:07 AM: ❯ Version
4:28:07 AM: @netlify/build 29.12.1
4:28:07 AM: ​
4:28:07 AM: ❯ Flags
4:28:07 AM: baseRelDir: true
4:28:07 AM: buildId: 648bd6b276cc9c00088daf86
4:28:07 AM: deployId: 648bd6b276cc9c00088daf88
4:28:07 AM: ​
4:28:07 AM: ❯ Current directory
4:28:07 AM: /opt/build/repo
4:28:07 AM: ​
4:28:07 AM: ❯ Config file
4:28:07 AM: /opt/build/repo/netlify.toml
4:28:07 AM: ​
4:28:07 AM: ❯ Context
4:28:07 AM: production
4:28:07 AM: ​
4:28:07 AM: ❯ Loading plugins
4:28:07 AM: - @netlify/[email protected] from Netlify app
4:28:07 AM: - @netlify/[email protected] from Netlify app
4:28:09 AM: ​
4:28:09 AM: build.command from netlify.toml
4:28:09 AM: ────────────────────────────────────────────────────────────────
4:28:09 AM: ​
4:28:09 AM: $ npm run build
4:28:09 AM: > [email protected] build
4:28:09 AM: > cross-env npm-run-all build:sass build:scripts build:eleventy
4:28:10 AM: > [email protected] build:sass
4:28:10 AM: > sass --no-source-map src/assets/scss/main.scss _site/assets/css/main.css
4:28:10 AM: > [email protected] build:scripts
4:28:10 AM: > esbuild ./src/assets/js/main.js --target=es6 --bundle --minify --outfile=./_site/assets/js/main.bundle.js
4:28:10 AM: _site/assets/js/main.bundle.js 39.8kb
4:28:10 AM: ⚡ Done in 8ms
4:28:10 AM: > [email protected] build:eleventy
4:28:10 AM: > eleventy
4:28:11 AM: Problem writing Eleventy templates: (more in DEBUG output)
4:28:11 AM: > Having trouble rendering njk template ./src/index.njk
4:28:11 AM: TemplateContentRenderError was thrown
4:28:11 AM: > (./src/index.njk)
4:28:11 AM: EleventyShortcodeError: Error with Nunjucks shortcode image
4:28:11 AM: Template render error was thrown
4:28:11 AM: > ENOENT: no such file or directory, stat '/src/assets/img/fern-forest.jpeg'
4:28:11 AM: Template render error was thrown:
4:28:11 AM: Error: ENOENT: no such file or directory, stat '/src/assets/img/fern-forest.jpeg'
4:28:11 AM: at Object.statSync (node:fs:1583:3)
4:28:11 AM: at Image.getInMemoryCacheKey (/opt/build/repo/node_modules/@11ty/eleventy-img/img.js:156:32)
4:28:11 AM: at queueImage (/opt/build/repo/node_modules/@11ty/eleventy-img/img.js:614:15)
4:28:11 AM: at Object.imageShortcode (/opt/build/repo/src/_11ty/shortcodes/image-shortcode.js:4:24)
4:28:11 AM: at Object. (/opt/build/repo/node_modules/@11ty/eleventy/src/BenchmarkGroup.js:30:26)
4:28:11 AM: at ShortcodeFunction.run (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:120:14)
4:28:11 AM: at Template.root [as rootRenderFunc] (eval at _compile (/opt/build/repo/node_modules/nunjucks/src/environment.js:527:18), :20:33)
4:28:11 AM: at Template.render (/opt/build/repo/node_modules/nunjucks/src/environment.js:454:10)
4:28:11 AM: at /opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:236:14
4:28:11 AM: at new Promise ()
4:28:11 AM: Copied 18 files / Wrote 0 files in 0.26 seconds (v0.11.1)
4:28:11 AM: ERROR: build:eleventy exited with 1.
4:28:11 AM: ​
4:28:11 AM: build.command failed
4:28:11 AM: ────────────────────────────────────────────────────────────────
4:28:11 AM: ​
4:28:11 AM: Error message
4:28:11 AM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
4:28:11 AM: ​
4:28:11 AM: Error location
4:28:11 AM: In build.command from netlify.toml:
4:28:11 AM: npm run build
4:28:11 AM: ​
4:28:11 AM: Resolved config
4:28:11 AM: build:
4:28:11 AM: command: npm run build
4:28:11 AM: commandOrigin: config
4:28:11 AM: publish: /opt/build/repo/_site
4:28:11 AM: publishOrigin: config
4:28:11 AM: plugins:
4:28:11 AM: - inputs: {}
4:28:11 AM: origin: ui
4:28:11 AM: package: '@netlify/plugin-lighthouse'
4:28:11 AM: - inputs: {}
4:28:11 AM: origin: ui
4:28:11 AM: package: '@netlify/plugin-sitemap'
4:28:12 AM: Caching artifacts
4:28:12 AM: Started saving node modules
4:28:12 AM: Finished saving node modules
4:28:12 AM: Started saving build plugins
4:28:12 AM: Finished saving build plugins
4:28:12 AM: Started saving corepack cache
4:28:12 AM: Finished saving corepack cache
4:28:12 AM: Started saving pip cache
4:28:12 AM: Finished saving pip cache
4:28:12 AM: Started saving emacs cask dependencies
4:28:12 AM: Finished saving emacs cask dependencies
4:28:12 AM: Started saving maven dependencies
4:28:12 AM: Finished saving maven dependencies
4:28:12 AM: Started saving boot dependencies
4:28:12 AM: Finished saving boot dependencies
4:28:12 AM: Started saving rust rustup cache
4:28:12 AM: Finished saving rust rustup cache
4:28:12 AM: Started saving go dependencies
4:28:12 AM: Finished saving go dependencies
4:28:12 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:28:12 AM: Failing build: Failed to build site
4:28:12 AM: Finished processing build request in 23.858s
Deploy log from Netlify
4:27:47 AM: Build ready to start
4:28:12 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:27:49 AM: build-image version: c11c0eb9939c949586b0f78302107908b668a11e (focal)
4:27:49 AM: buildbot version: c11c0eb9939c949586b0f78302107908b668a11e
4:27:49 AM: Fetching cached dependencies
4:27:49 AM: Starting to download cache of 273.1MB
4:27:53 AM: Finished downloading cache in 3.97s
4:27:53 AM: Starting to extract cache
4:27:55 AM: Finished extracting cache in 2.042s
4:27:55 AM: Finished fetching cache in 6.103s
4:27:55 AM: Starting to prepare the repo for build
4:27:55 AM: Preparing Git Reference refs/heads/master
4:27:57 AM: Starting to install dependencies
4:27:57 AM: Python version set to 3.8
4:27:57 AM: Attempting Ruby version 2.7.2, read from environment
4:27:58 AM: Using Ruby version 2.7.2
4:27:58 AM: Started restoring cached go cache
4:27:58 AM: Finished restoring cached go cache
4:27:58 AM: go version go1.19.10 linux/amd64
4:27:59 AM: Using PHP version 8.0
4:28:00 AM: Started restoring cached Node.js version
4:28:00 AM: Finished restoring cached Node.js version
4:28:00 AM: Attempting Node.js version '16' from .nvmrc
4:28:01 AM: v16.20.0 is already installed.
4:28:01 AM: Now using node v16.20.0 (npm v8.19.4)
4:28:01 AM: Enabling Node.js Corepack
4:28:01 AM: Started restoring cached build plugins
4:28:01 AM: Finished restoring cached build plugins
4:28:01 AM: Started restoring cached corepack dependencies
4:28:01 AM: Finished restoring cached corepack dependencies
4:28:01 AM: No npm workspaces detected
4:28:01 AM: Started restoring cached node modules
4:28:01 AM: Finished restoring cached node modules
4:28:01 AM: Installing npm packages using npm version 8.19.4
4:28:04 AM: up to date, audited 592 packages in 3s
4:28:04 AM: 105 packages are looking for funding
4:28:04 AM: run npm fund for details
4:28:04 AM: 5 vulnerabilities (2 moderate, 1 high, 2 critical)
4:28:04 AM: To address all issues (including breaking changes), run:
4:28:04 AM: npm audit fix --force
4:28:04 AM: Run npm audit for details.
4:28:04 AM: npm packages installed
4:28:05 AM: Install dependencies script success
4:28:05 AM: Starting build script
4:28:06 AM: Detected 1 framework(s)
4:28:06 AM: eleventy at version 0.11.1
4:28:06 AM: Section completed: initializing
4:28:07 AM: ​
4:28:07 AM: Netlify Build
4:28:07 AM: ────────────────────────────────────────────────────────────────
4:28:07 AM: ​
4:28:07 AM: ❯ Version
4:28:07 AM: @netlify/build 29.12.1
4:28:07 AM: ​
4:28:07 AM: ❯ Flags
4:28:07 AM: baseRelDir: true
4:28:07 AM: buildId: 648bd6b276cc9c00088daf86
4:28:07 AM: deployId: 648bd6b276cc9c00088daf88
4:28:07 AM: ​
4:28:07 AM: ❯ Current directory
4:28:07 AM: /opt/build/repo
4:28:07 AM: ​
4:28:07 AM: ❯ Config file
4:28:07 AM: /opt/build/repo/netlify.toml
4:28:07 AM: ​
4:28:07 AM: ❯ Context
4:28:07 AM: production
4:28:07 AM: ​
4:28:07 AM: ❯ Loading plugins
4:28:07 AM: - @netlify/[email protected] from Netlify app
4:28:07 AM: - @netlify/[email protected] from Netlify app
4:28:09 AM: ​
4:28:09 AM: build.command from netlify.toml
4:28:09 AM: ────────────────────────────────────────────────────────────────
4:28:09 AM: ​
4:28:09 AM: $ npm run build
4:28:09 AM: > [email protected] build
4:28:09 AM: > cross-env npm-run-all build:sass build:scripts build:eleventy
4:28:10 AM: > [email protected] build:sass
4:28:10 AM: > sass --no-source-map src/assets/scss/main.scss _site/assets/css/main.css
4:28:10 AM: > [email protected] build:scripts
4:28:10 AM: > esbuild ./src/assets/js/main.js --target=es6 --bundle --minify --outfile=./_site/assets/js/main.bundle.js
4:28:10 AM: _site/assets/js/main.bundle.js 39.8kb
4:28:10 AM: ⚡ Done in 8ms
4:28:10 AM: > [email protected] build:eleventy
4:28:10 AM: > eleventy
4:28:11 AM: Problem writing Eleventy templates: (more in DEBUG output)
4:28:11 AM: > Having trouble rendering njk template ./src/index.njk
4:28:11 AM: TemplateContentRenderError was thrown
4:28:11 AM: > (./src/index.njk)
4:28:11 AM: EleventyShortcodeError: Error with Nunjucks shortcode image
4:28:11 AM: Template render error was thrown
4:28:11 AM: > ENOENT: no such file or directory, stat '/src/assets/img/fern-forest.jpeg'
4:28:11 AM: Template render error was thrown:
4:28:11 AM: Error: ENOENT: no such file or directory, stat '/src/assets/img/fern-forest.jpeg'
4:28:11 AM: at Object.statSync (node:fs:1583:3)
4:28:11 AM: at Image.getInMemoryCacheKey (/opt/build/repo/node_modules/@11ty/eleventy-img/img.js:156:32)
4:28:11 AM: at queueImage (/opt/build/repo/node_modules/@11ty/eleventy-img/img.js:614:15)
4:28:11 AM: at Object.imageShortcode (/opt/build/repo/src/_11ty/shortcodes/image-shortcode.js:4:24)
4:28:11 AM: at Object. (/opt/build/repo/node_modules/@11ty/eleventy/src/BenchmarkGroup.js:30:26)
4:28:11 AM: at ShortcodeFunction.run (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:120:14)
4:28:11 AM: at Template.root [as rootRenderFunc] (eval at _compile (/opt/build/repo/node_modules/nunjucks/src/environment.js:527:18), :20:33)
4:28:11 AM: at Template.render (/opt/build/repo/node_modules/nunjucks/src/environment.js:454:10)
4:28:11 AM: at /opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:236:14
4:28:11 AM: at new Promise ()
4:28:11 AM: Copied 18 files / Wrote 0 files in 0.26 seconds (v0.11.1)
4:28:11 AM: ERROR: build:eleventy exited with 1.
4:28:11 AM: ​
4:28:11 AM: build.command failed
4:28:11 AM: ────────────────────────────────────────────────────────────────
4:28:11 AM: ​
4:28:11 AM: Error message
4:28:11 AM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
4:28:11 AM: ​
4:28:11 AM: Error location
4:28:11 AM: In build.command from netlify.toml:
4:28:11 AM: npm run build
4:28:11 AM: ​
4:28:11 AM: Resolved config
4:28:11 AM: build:
4:28:11 AM: command: npm run build
4:28:11 AM: commandOrigin: config
4:28:11 AM: publish: /opt/build/repo/_site
4:28:11 AM: publishOrigin: config
4:28:11 AM: plugins:
4:28:11 AM: - inputs: {}
4:28:11 AM: origin: ui
4:28:11 AM: package: '@netlify/plugin-lighthouse'
4:28:11 AM: - inputs: {}
4:28:11 AM: origin: ui
4:28:11 AM: package: '@netlify/plugin-sitemap'
4:28:12 AM: Caching artifacts
4:28:12 AM: Started saving node modules
4:28:12 AM: Finished saving node modules
4:28:12 AM: Started saving build plugins
4:28:12 AM: Finished saving build plugins
4:28:12 AM: Started saving corepack cache
4:28:12 AM: Finished saving corepack cache
4:28:12 AM: Started saving pip cache
4:28:12 AM: Finished saving pip cache
4:28:12 AM: Started saving emacs cask dependencies
4:28:12 AM: Finished saving emacs cask dependencies
4:28:12 AM: Started saving maven dependencies
4:28:12 AM: Finished saving maven dependencies
4:28:12 AM: Started saving boot dependencies
4:28:12 AM: Finished saving boot dependencies
4:28:12 AM: Started saving rust rustup cache
4:28:12 AM: Finished saving rust rustup cache
4:28:12 AM: Started saving go dependencies
4:28:12 AM: Finished saving go dependencies
4:28:12 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:28:12 AM: Failing build: Failed to build site
4:28:12 AM: Finished processing build request in 23.858s

@TylerMRoderick
Copy link
Owner

Hey @empoweragency, thanks for opening an issue.

Looking at your error message, this line stands out to me
Error: ENOENT: no such file or directory, stat '/src/assets/img/fern-forest.jpeg'

fern-forest.jpeg is the image on the about page, not the home page. Did you happen to delete that image? If so, I recommend you remove this line from your about page.

Let me know if that works for you.

@Daxuras
Copy link

Daxuras commented Oct 9, 2023

I got the same problem. Interesting is, that even if i change the image back to one of the presetted ones, i get an error.

DId the problem solved by someone, or got a workaround?

@TylerMRoderick
Copy link
Owner

@Daxuras thanks for commenting. I just reproduced this on my end and it is related to adding images through crm. I will take a deeper look later this week. For now, you can update the file path for any broken images manually in your code. That should require either removing (or adding) a "/" before any problematic image paths.

For example: change "src/assets/img/fern-forest.jpeg"... to "/src/assets/img/fern-forest.jpeg".

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

3 participants