Search code examples
githubthemesgithub-pageshugonetlify

Error in building a Hugo site on netlify because of exit error status 127


I am building a static site using Hugo, netlify, and github. But I am getting the error on the last line with exit code 127 about the building site script. What is this script and how do i fix this. LINK -Github repo I am a very beginner. Thanks in advance

    5:10:09 PM: Build ready to start
5:10:10 PM: build-image version: 42bca793ccd33055023c56c4ca8510463a56d317
5:10:10 PM: buildbot version: 15854c92f1b74f9c77ad951b5536193c76eff25e
5:10:11 PM: Fetching cached dependencies
5:10:11 PM: Starting to download cache of 16.7MB
5:10:11 PM: Finished downloading cache in 209.623278ms
5:10:11 PM: Starting to extract cache
5:10:11 PM: Finished extracting cache in 184.94328ms
5:10:11 PM: Finished fetching cache in 452.033931ms
5:10:11 PM: Starting to prepare the repo for build
5:10:11 PM: Preparing Git Reference refs/heads/master
5:10:12 PM: Starting build script
5:10:12 PM: Installing dependencies
5:10:13 PM: Downloading and installing node v8.12.0...
5:10:13 PM: Downloading https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz...
5:10:14 PM:   0.9%
5:10:14 PM: 
#####################
5:10:14 PM:                                                     30.3%
5:10:14 PM: 
#################################
5:10:14 PM: ####################################### 100.0%
5:10:14 PM: Computing checksum with sha256sum
5:10:14 PM: Checksums matched!
5:10:16 PM: Now using node v8.12.0 (npm v6.4.1)
5:10:17 PM: Attempting ruby version 2.3.6, read from environment
5:10:18 PM: Using ruby version 2.3.6
5:10:18 PM: Using PHP version 5.6
5:10:18 PM: Installing Hugo 0.41
5:10:19 PM: Started restoring cached go cache
5:10:19 PM: Finished restoring cached go cache
5:10:19 PM: unset GOOS;
5:10:19 PM: unset GOARCH;
5:10:19 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
5:10:19 PM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
5:10:19 PM: go version >&2;
5:10:20 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
5:10:20 PM: go version go1.10 linux/amd64
5:10:20 PM: Installing missing commands
5:10:20 PM: Verify run directory
5:10:20 PM: Executing user command: hugo_0.41
5:10:20 PM: /usr/local/bin/build: line 32: hugo_0.41: command not found
5:10:20 PM: Caching artifacts
5:10:20 PM: Started saving pip cache
5:10:20 PM: Finished saving pip cache
5:10:20 PM: Started saving emacs cask dependencies
5:10:20 PM: Finished saving emacs cask dependencies
5:10:20 PM: Started saving maven dependencies
5:10:20 PM: Finished saving maven dependencies
5:10:20 PM: Started saving boot dependencies
5:10:20 PM: Finished saving boot dependencies
5:10:20 PM: Started saving go dependencies
5:10:20 PM: Finished saving go dependencies
5:10:20 PM: Cached node version v8.12.0
5:10:20 PM: Error running command: Build script returned non-zero exit code: 127
5:10:20 PM: Failing build: Failed to build site
5:10:20 PM: failed during stage 'building site': Build script returned non-zero exit code: 127
5:10:20 PM: Finished processing build request in 9.957599589s

Solution

  • Netlify is using the command hugo_0.41 which is incorrect to build Hugo

    Executing user command: hugo_0.41

    When there is a non-zero exit code, your site build will fail and will not deploy.

    Error running command: Build script returned non-zero exit code: 127

    Solution

    Fix this by running the correct command for a production build hugo. Also setup the Hugo version to your target version, which looks like it is version 0.41

    The easiest way to control this from your repository is to create a netlify.toml file in the root of your repository.

    netlify.toml

    [build]
      command = "hugo"
      publish = "public"
    
    [build.environment]
      HUGO_VERSION = "0.41"
    

    Note: The values in the netlify.toml can be set in the app.netlify.com online admin also, but netlify.toml will override these values and can also be used for more advanced settings later. You could also test out a different version of Hugo by changing the version number.