Hi everyone,
I’m encountering an issue deploying my Hugo site, created using RStudio and the blogdown library. The build fails with the error: Build script returned non-zero exit code: 2
Here are the details of my setup:
- Netlify Site Name: https://cinemateatrosestito.netlify.app
- Custom Domain: https://cinemateatrosestito.com
- Hugo Version: 0.136.5
- Publish Directory: public
Build Settings & Logs:
Build Setting screenshot:
I copy here the log of the failed deployment:
Summary
7:32:54 PM: build-image version: 044a471eb752a4c45159cdf15dd17713312bf318 (focal)
7:32:54 PM: buildbot version: cb208300f207dc39831223d4086208479ded63c7
7:32:54 PM: Fetching cached dependencies
7:32:54 PM: Failed to fetch cache, continuing with build
7:32:54 PM: Starting to prepare the repo for build
7:32:54 PM: No cached dependencies found. Cloning fresh repo
7:32:54 PM: git clone --filter=blob:none GitHub - whatswrongintown/cinema-teatro-sestito: Un sito web dedicato al Cinema Teatro Sestito
7:32:55 PM: Preparing Git Reference refs/heads/main
7:33:00 PM: Starting to install dependencies
7:33:02 PM: mise python@3.13.2 install
7:33:02 PM: mise python@3.13.2 download cpython-3.13.2+20250311-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
7:33:02 PM: mise python@3.13.2 extract cpython-3.13.2+20250311-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
7:33:03 PM: mise python@3.13.2 python --version
7:33:03 PM: mise python@3.13.2 Python 3.13.2
7:33:03 PM: mise python@3.13.2 ✓ installed
7:33:03 PM: Python version set to 3.13
7:33:04 PM: Collecting pipenv
7:33:04 PM: Downloading pipenv-2024.4.1-py3-none-any.whl.metadata (17 kB)
7:33:04 PM: Collecting certifi (from pipenv)
7:33:04 PM: Downloading certifi-2025.1.31-py3-none-any.whl.metadata (2.5 kB)
7:33:05 PM: Collecting packaging>=22 (from pipenv)
7:33:05 PM: Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
7:33:05 PM: Collecting setuptools>=67 (from pipenv)
7:33:05 PM: Downloading setuptools-76.0.0-py3-none-any.whl.metadata (6.7 kB)
7:33:05 PM: Collecting virtualenv>=20.24.2 (from pipenv)
7:33:05 PM: Downloading virtualenv-20.29.3-py3-none-any.whl.metadata (4.5 kB)
7:33:05 PM: Collecting distlib<1,>=0.3.7 (from virtualenv>=20.24.2->pipenv)
7:33:05 PM: Downloading distlib-0.3.9-py2.py3-none-any.whl.metadata (5.2 kB)
7:33:05 PM: Collecting filelock<4,>=3.12.2 (from virtualenv>=20.24.2->pipenv)
7:33:05 PM: Downloading filelock-3.18.0-py3-none-any.whl.metadata (2.9 kB)
7:33:05 PM: Collecting platformdirs<5,>=3.9.1 (from virtualenv>=20.24.2->pipenv)
7:33:05 PM: Downloading platformdirs-4.3.6-py3-none-any.whl.metadata (11 kB)
7:33:05 PM: Downloading pipenv-2024.4.1-py3-none-any.whl (3.0 MB)
7:33:05 PM: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 42.4 MB/s eta 0:00:00
7:33:05 PM: Downloading packaging-24.2-py3-none-any.whl (65 kB)
7:33:05 PM: Downloading setuptools-76.0.0-py3-none-any.whl (1.2 MB)
7:33:05 PM: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 27.4 MB/s eta 0:00:00
7:33:05 PM: Downloading virtualenv-20.29.3-py3-none-any.whl (4.3 MB)
7:33:05 PM: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 72.8 MB/s eta 0:00:00
7:33:05 PM: Downloading certifi-2025.1.31-py3-none-any.whl (166 kB)
7:33:05 PM: Downloading distlib-0.3.9-py2.py3-none-any.whl (468 kB)
7:33:05 PM: Downloading filelock-3.18.0-py3-none-any.whl (16 kB)
7:33:06 PM: Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
7:33:06 PM: Installing collected packages: distlib, setuptools, platformdirs, packaging, filelock, certifi, virtualenv, pipenv
7:33:08 PM: Successfully installed certifi-2025.1.31 distlib-0.3.9 filelock-3.18.0 packaging-24.2 pipenv-2024.4.1 platformdirs-4.3.6 setuptools-76.0.0 virtualenv-20.29.3
7:33:08 PM: [notice] A new release of pip is available: 24.3.1 → 25.0.1
7:33:08 PM: [notice] To update, run: pip install --upgrade pip
7:33:09 PM: Attempting Ruby version 2.7.2, read from environment
7:33:09 PM: Using Ruby version 2.7.2
7:33:10 PM: Started restoring cached go cache
7:33:10 PM: Finished restoring cached go cache
7:33:12 PM: go version go1.19.13 linux/amd64
7:33:13 PM: Using PHP version 8.0
7:33:13 PM: Installing Hugo 0.136.5
7:33:14 PM: hugo v0.136.5-46cccb021bc6425455f4eec093f5cc4a32f1d12c+extended linux/amd64 BuildDate=2024-10-24T12:26:27Z VendorInfo=gohugoio
7:33:15 PM: Downloading and installing node v20.19.0…
7:33:15 PM: Downloading https://nodejs.org/dist/v20.19.0/node-v20.19.0-linux-x64.tar.xz…
7:33:16 PM: Computing checksum with sha256sum
7:33:16 PM: Checksums matched!
7:33:18 PM: Now using node v20.19.0 (npm v10.8.2)
7:33:18 PM: Enabling Node.js Corepack
7:33:18 PM: Started restoring cached build plugins
7:33:18 PM: Finished restoring cached build plugins
7:33:19 PM: Successfully installed dependencies
7:33:19 PM: Starting build script
7:33:20 PM: Detected 1 framework(s)
7:33:20 PM: “hugo” at version “unknown”
7:33:20 PM: Section completed: initializing
7:33:21 PM:
7:33:21 PM: Netlify Build
7:33:21 PM: ────────────────────────────────────────────────────────────────
7:33:21 PM:
7:33:21 PM: ❯ Version
7:33:21 PM: @netlify/build 29.59.2
7:33:21 PM:
7:33:21 PM: ❯ Flags
7:33:21 PM: accountId: 643ad2d33f8df4575a2a716f
7:33:21 PM: baseRelDir: true
7:33:21 PM: buildId: 67d47646484d380008c759b2
7:33:21 PM: deployId: 67d47646484d380008c759b4
7:33:21 PM:
7:33:21 PM: ❯ Current directory
7:33:21 PM: /opt/build/repo
7:33:21 PM:
7:33:21 PM: ❯ Config file
7:33:21 PM: /opt/build/repo/netlify.toml
7:33:21 PM:
7:33:21 PM: ❯ Context
7:33:21 PM: production
7:33:22 PM:
7:33:22 PM: ❯ Installing plugins
7:33:22 PM: - @netlify/plugin-lighthouse@6.0.1
7:33:32 PM:
7:33:32 PM: ❯ Loading plugins
7:33:32 PM: - @netlify/plugin-lighthouse@6.0.1 from Netlify app
7:33:33 PM:
7:33:33 PM: build.command from netlify.toml
7:33:33 PM: ────────────────────────────────────────────────────────────────
7:33:33 PM:
7:33:33 PM: $ hugo
7:33:33 PM: Start building sites …
7:33:33 PM: hugo v0.136.5-46cccb021bc6425455f4eec093f5cc4a32f1d12c+extended linux/amd64 BuildDate=2024-10-24T12:26:27Z VendorInfo=gohugoio
7:34:10 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
7:34:10 PM: ERROR render of “page” failed: “/opt/build/repo/layouts/_default/single.html:1:3”: execute of template failed: template: _default/single.html:1:3: executing “_default/single.html” at <partial “header.html” .>: error calling partial: “/opt/build/repo/themes/hugo-lithium/layouts/partials/header.html:4:7”: execute of template failed: template: partials/header.html:4:7: executing “partials/header.html” at <partial “head.html” .>: error calling partial: partial “head.html” timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the ‘timeout’ config setting.
7:34:10 PM: ERROR render of “page” failed: “/opt/build/repo/layouts/_default/single.html:1:3”: execute of template failed: template: _default/single.html:1:3: executing “_default/single.html” at <partial “header.html” .>: error calling partial: partial “header.html” timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the ‘timeout’ config setting.
7:34:10 PM: Total in 36446 ms
7:34:10 PM: Error: error building site: render: failed to render pages: render of “page” failed: “/opt/build/repo/layouts/_default/single.html:1:3”: execute of template failed: template: _default/single.html:1:3: executing “_default/single.html” at <partial “header.html” .>: error calling partial: “/opt/build/repo/themes/hugo-lithium/layouts/partials/header.html:4:7”: execute of template failed: template: partials/header.html:4:7: executing “partials/header.html” at <partial “head.html” .>: error calling partial: partial “head.html” timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the ‘timeout’ config setting.
7:34:10 PM:
7:34:10 PM: “build.command” failed
7:34:10 PM: ────────────────────────────────────────────────────────────────
7:34:10 PM:
7:34:10 PM: Error message
7:34:10 PM: Command failed with exit code 1: hugo (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
7:34:10 PM:
7:34:10 PM: Error location
7:34:10 PM: In build.command from netlify.toml:
7:34:10 PM: hugo
7:34:10 PM:
7:34:10 PM: Resolved config
7:34:10 PM: build:
7:34:10 PM: command: hugo
7:34:10 PM: commandOrigin: config
7:34:10 PM: environment:
7:34:10 PM: - HUGO_VERSION
7:34:10 PM: - HUGO_ENV
7:34:10 PM: publish: /opt/build/repo/public
7:34:10 PM: publishOrigin: config
7:34:10 PM: plugins:
7:34:10 PM: - inputs: {}
7:34:10 PM: origin: ui
7:34:10 PM: package: ‘@netlify/plugin-lighthouse’
7:34:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:34:10 PM: Failing build: Failed to build site
7:34:10 PM: Finished processing build request in 1m16.422s
Additional Context:
- I verified that the site works perfectly in my local environment by using the blogdown function
serve_site()
in RStudio. - I ensured Hugo is installed in the build environment and set the correct Hugo version in Netlify.
- I’ve also consulted “Why did it fails” many times, and Netlify’s Ask Netlify chatbot and the Support Guide and this Formu, but I couldn’t find a solution.
- I’ve tried to check my layouts, partials and shortcodes, but are working fine on my local environment.
Any assistance would be greatly appreciated. Thank you in advance!