# Build script returned non-zero exit code

**URL:** <https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441>\
**Category:** Support\
**Tags:** deployment\
**Created:** [December 17, 2022, 4:01pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441 "2022-12-17T16:01:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gao-xiao](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/gao-xiao/32/41410_2.png) [@Gao-xiao](https://answers.netlify.com/u/Gao-xiao)\
**Post date:** [December 17, 2022, 4:01pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/1 "2022-12-17T16:01:38Z")

</div>

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](https://answers.netlify.com/t/building-script-returned-non-zero-exit-code-2/49827)"  
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](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](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](https://ntl.fyi/exit-code-2))  
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](https://ntl.fyi/exit-code-255))  
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

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [December 17, 2022, 4:30pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/2 "2022-12-17T16:30:59Z")

</div>

Please check out this:

> [@Exit code error](https://answers.netlify.com/t/81391/12):
>
> Either in netlify.toml like: [build.environment] GO\_VERSION = "1.19.4" or in your Site Settings (on Netlify UI) → Environment Variables.

---

<div class="post-metadata">

**Author:** ![danez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/danez/32/38911_2.png) [@danez](https://answers.netlify.com/u/danez)\
**Post date:** [December 17, 2022, 6:49pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/3 "2022-12-17T18:49:47Z")

</div>

As per this:

> **[Go binary installation failure in Netlify Builds](https://www.netlifystatus.com/incidents/pz5z012zd13l)**
>
> Netlify's Status Page - Go binary installation failure in Netlify Builds.

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

---

<div class="post-metadata">

**Author:** ![Gao-xiao](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/gao-xiao/32/41410_2.png) [@Gao-xiao](https://answers.netlify.com/u/Gao-xiao)\
**Post date:** [December 18, 2022, 6:40pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/4 "2022-12-18T18:40:27Z")

</div>

[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?

---

<div class="post-metadata">

**Author:** ![Gao-xiao](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/gao-xiao/32/41410_2.png) [@Gao-xiao](https://answers.netlify.com/u/Gao-xiao)\
**Post date:** [December 18, 2022, 6:44pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/5 "2022-12-18T18:44:14Z")

</div>

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?

```auto
# 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
}

```

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [December 18, 2022, 6:48pm UTC](https://answers.netlify.com/t/build-script-returned-non-zero-exit-code/81441/6 "2022-12-18T18:48:50Z")

</div>

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

> [@Gao-xiao](#):
>
> 11:51:48 PM: Error: failed to download modules: binary with name “go” not found

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