Build script returned non-zero exit code

When i deploy on netlify, it is not. What is the issue? There is always an error " Building script returned non zero exit code:2"
Does any one know what is the reason of this issue?

11:51:38 PM: build-image version: 524714d1a66d1a967316f5c39465e22c77fdd56c (focal)
11:51:38 PM: build-image tag: v4.16.0
11:51:38 PM: buildbot version: ccca89b58bb45671b9608069deb629f8ca866189
11:51:38 PM: Fetching cached dependencies
11:51:38 PM: Failed to fetch cache, continuing with build
11:51:38 PM: Starting to prepare the repo for build
11:51:38 PM: No cached dependencies found. Cloning fresh repo
11:51:38 PM: git clone https://github.com/gaoxiao0041/Aca-HP
11:51:38 PM: Preparing Git Reference refs/heads/main
11:51:38 PM: Parsing package.json dependencies
11:51:39 PM: Different build command detected, going to use the one specified in the Netlify configuration file: ‘hugo --gc --minify’ versus ‘hugo --gc --minify -b $URL’ in the Netlify UI
11:51:39 PM: Section completed: initializing
11:51:39 PM: Starting build script
11:51:39 PM: Installing dependencies
11:51:39 PM: Python version set to 2.7
11:51:40 PM: Downloading and installing node v16.19.0…
11:51:40 PM: Downloading https://nodejs.org/dist/v16.19.0/node-v16.19.0-linux-x64.tar.xz
11:51:41 PM: Computing checksum with sha256sum
11:51:41 PM: Checksums matched!
11:51:43 PM: Now using node v16.19.0 (npm v8.19.3)
11:51:43 PM: Enabling node corepack
11:51:43 PM: Started restoring cached build plugins
11:51:43 PM: Finished restoring cached build plugins
11:51:43 PM: Attempting ruby version 2.7.2, read from environment
11:51:44 PM: Using ruby version 2.7.2
11:51:44 PM: Using PHP version 8.0
11:51:44 PM: Installing Hugo 0.108.0
11:51:45 PM: hugo v0.108.0-a0d64a46e36dd2f503bfd5ba1a5807b900df231d+extended linux/amd64 BuildDate=2022-12-06T13:37:56Z VendorInfo=gohugoio
11:51:45 PM: Started restoring cached go cache
11:51:45 PM: Finished restoring cached go cache
11:51:46 PM: go version go1.19.4 linux/amd64
11:51:46 PM: /opt/build-bin/run-build-functions.sh: line 1034: /opt/buildhome/.gimme/env/go1.19.x.linux.amd64.env: No such file or directory
11:51:47 PM: Detected 0 framework(s)
11:51:47 PM: Installing missing commands
11:51:47 PM: Verify run directory
11:51:48 PM: ​
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: Netlify Build
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: ​
11:51:48 PM: ❯ Version
11:51:48 PM: @netlify/build 29.1.2
11:51:48 PM: ​
11:51:48 PM: ❯ Flags
11:51:48 PM: baseRelDir: true
11:51:48 PM: buildId: 639de588ec217c0009602b2c
11:51:48 PM: deployId: 639de588ec217c0009602b2e
11:51:48 PM: ​
11:51:48 PM: ❯ Current directory
11:51:48 PM: /opt/build/repo
11:51:48 PM: ​
11:51:48 PM: ❯ Config file
11:51:48 PM: /opt/build/repo/netlify.toml
11:51:48 PM: ​
11:51:48 PM: ❯ Context
11:51:48 PM: production
11:51:48 PM: ​
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: 1. build.command from netlify.toml
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: ​
11:51:48 PM: $ hugo --gc --minify
11:51:48 PM: Error: failed to download modules: binary with name “go” not found
11:51:48 PM: Total in 0 ms
11:51:48 PM: ​
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: “build.command” failed
11:51:48 PM: ────────────────────────────────────────────────────────────────
11:51:48 PM: ​
11:51:49 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)
11:51:48 PM: Error message
11:51:48 PM: Command failed with exit code 255: hugo --gc --minify (Search results for '"non-zero exit code: 255"' - Netlify Support Forums)
11:51:48 PM: ​
11:51:48 PM: Error location
11:51:48 PM: In build.command from netlify.toml:
11:51:48 PM: hugo --gc --minify
11:51:48 PM: ​
11:51:48 PM: Resolved config
11:51:48 PM: build:
11:51:48 PM: command: hugo --gc --minify
11:51:48 PM: commandOrigin: config
11:51:48 PM: environment:
11:51:48 PM: - HUGO_VERSION
11:51:48 PM: - HUGO_ENV
11:51:48 PM: - HUGO_ENABLEGITINFO
11:51:48 PM: publish: /opt/build/repo/public
11:51:48 PM: publishOrigin: config
11:51:48 PM: redirects:
11:51:48 PM: - from: /npmjs/* status: 200 to: /npmjs/ redirectsOrigin: configCaching artifacts
11:51:48 PM: Started saving build plugins
11:51:48 PM: Finished saving build plugins
11:51:48 PM: Started saving pip cache
11:51:48 PM: Finished saving pip cache
11:51:48 PM: Started saving emacs cask dependencies
11:51:48 PM: Finished saving emacs cask dependencies
11:51:48 PM: Started saving maven dependencies
11:51:48 PM: Finished saving maven dependencies
11:51:48 PM: Started saving boot dependencies
11:51:48 PM: Finished saving boot dependencies
11:51:48 PM: Started saving rust rustup cache
11:51:48 PM: Finished saving rust rustup cache
11:51:48 PM: Started saving go dependencies
11:51:48 PM: Finished saving go dependencies
11:51:49 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:51:49 PM: Failing build: Failed to build site
11:51:49 PM: Finished processing build request in 11.689903232s

Please check out this:

As per this:

The issue (Go binary problem) is now resolved, and users do not need set the environment variable manually anymore.

[quote=“Exit code error, post:12, topic:81391”]
netlify.toml
[/quote] Thanks, but there is no nelify.toml in my repository. Considering Environment Variables in the Site Settings , which variable and how much should I set?

I just checked what you told me and only found a file named update_wowchey.sh, here I clone the related script. Does it mean that the Netlify.toml will automatically update?

# Update Netlify config
function update_netlify () {
  # - Update Netlify.toml with required Hugo version
  if [ -f ./netlify.toml ]; then
    echo "Attempting to get compatible Hugo version from https://raw.githubusercontent.com/wowchemy/wowchemy-hugo-modules/main/wowchemy/config.yaml ..."
    curl -o "tmp_get_version" https://raw.githubusercontent.com/wowchemy/wowchemy-hugo-modules/main/wowchemy/config.yaml
    version=$(sed -n 's/^[[:space:]]*min: //p' "tmp_get_version" | tr -d "'")
    version="${version}"
    echo "Set Netlify Hugo version to v${version}"
    sed -i.bak -e "s/HUGO_VERSION = .*/HUGO_VERSION = \"$version\"/g" ./netlify.toml && rm -f ./netlify.toml.bak
    rm tmp_get_version
  fi
}

I’m not sure what you’re saying. All we meant was, the error you were seeing before:

has been resolved and you need not do anything to fix it anymore. If you’ve some other error, please let us know accordingly.