Home
Support Forums

Help debugging build: "build.command" failed Error message Command failed with exit code 127: hugo_0.19

Hi there!

I need advice to debug deploy Netlify App

for my site

https://app.netlify.com/sites/violinist-patterns-57213

Subsequent to the Trusty build image deprecation notice sent out this morning, I have been attempting to switch my site to the Focal image.

I initially encountered problems with access rights/permissions after switching to the latest build image but resolved that by re-linking the same github repository using the app rather than Oauth.

This resolved the access rights issue. However, when following the instructions on the migration guide page and attempting to deploy a preview build (with auto-publishing disabled and locked to my latest successful build which dates back to 2019!) I am now getting a build failure error with an error related to the build command (see full build log for debugging below):

β€œbuild.command” failed

Command failed with exit code 127: hugo_0.19

[…]

Failed during stage β€˜building site’: Build script returned non-zero exit code: 2

It is very possible that this build command for hugo is no longer valid given that it is so long that I have run a build on the site.

I have searched the support pages and documentation and tried a few other possible build commands (npm run build / hugo / hugo_0.83.1) all to no avail, so was hoping someone on here might be able to point me in the right direction to get my build working again.

Thanks!

Build log follows…

11:49:28 AM: Build ready to start
11:49:29 AM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
11:49:29 AM: build-image tag: v4.3.0
11:49:29 AM: buildbot version: fd60e21d56897195475b3dbb3e1c495894eb873c
11:49:29 AM: Fetching cached dependencies
11:49:30 AM: Failed to fetch cache, continuing with build
11:49:30 AM: Starting to prepare the repo for build
11:49:30 AM: No cached dependencies found. Cloning fresh repo
11:49:30 AM: git clone GitHub - praetoriuspl/ppl-site
11:49:31 AM: Preparing Git Reference refs/heads/master
11:49:32 AM: Parsing package.json dependencies
11:49:32 AM:
​
❯ Initial build environment
baseRelDir: true
branch: master
context: production
cwd: /opt/build/repo
featureFlags:
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: ad29b9b3-a49d-4f75-9c32-d4151df2e4e0
​
❯ UI build settings
baseRelDir: true
build:
command: hugo_0.19
environment:
- NETLIFY_BUILD_DEBUG
- SITE_RECAPTCHA_KEY
- SITE_RECAPTCHA_SECRET
publish: public
​
❯ Resolved build environment
branch: master
buildDir: /opt/build/repo
context: production
env:
​
❯ Resolved config
build:
command: hugo_0.19
commandOrigin: ui
environment:
- NETLIFY_BUILD_DEBUG
- SITE_RECAPTCHA_KEY
- SITE_RECAPTCHA_SECRET
publish: /opt/build/repo/public
publishOrigin: ui

11:49:32 AM: Starting build script
11:49:32 AM: Installing dependencies
11:49:32 AM: Python version set to 2.7
11:49:33 AM: Downloading and installing node v16.8.0…
11:49:33 AM: Downloading https://nodejs.org/dist/v16.8.0/node-v16.8.0-linux-x64.tar.xz…
11:49:33 AM: Computing checksum with sha256sum
11:49:33 AM: Checksums matched!
11:49:36 AM: Now using node v16.8.0 (npm v7.21.0)
11:49:36 AM: Started restoring cached build plugins
11:49:36 AM: Finished restoring cached build plugins
11:49:36 AM: Attempting ruby version 2.7.2, read from environment
11:49:37 AM: Using ruby version 2.7.2
11:49:37 AM: Using PHP version 8.0
11:49:37 AM: Started restoring cached go cache
11:49:37 AM: Finished restoring cached go cache
11:49:37 AM: go version go1.16.5 linux/amd64
11:49:37 AM: go version go1.16.5 linux/amd64
11:49:37 AM: Installing missing commands
11:49:37 AM: Verify run directory
11:49:38 AM: ​
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: Netlify Build
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: ​
11:49:38 AM: ❯ Version
11:49:38 AM: @netlify/build 18.7.2
11:49:38 AM: ​
11:49:38 AM: ❯ Flags
11:49:38 AM: apiHost: api.netlify.com
11:49:38 AM: baseRelDir: true
11:49:38 AM: branch: master
11:49:38 AM: buildId: 612dfb28345a47cabf808551
11:49:38 AM: buildbotServerSocket: /tmp/netlify-buildbot-socket
11:49:38 AM: cacheDir: /opt/build/cache
11:49:38 AM: cachedConfigPath: /tmp/netlify_config.json
11:49:38 AM: context: production
11:49:38 AM: cwd: /opt/build/repo
11:49:38 AM: deployId: 612dfb28345a47cabf808553
11:49:38 AM: featureFlags:
11:49:38 AM: - zisiEsbuildDynamicImports
11:49:38 AM: framework: hugo
11:49:38 AM: functionsDistDir: /tmp/zisi-612dfb28345a47cabf808553
11:49:38 AM: mode: buildbot
11:49:38 AM: nodePath: /opt/buildhome/.nvm/versions/node/v16.8.0/bin/node
11:49:38 AM: repositoryRoot: /opt/build/repo
11:49:38 AM: saveConfig: true
11:49:38 AM: sendStatus: true
11:49:38 AM: siteId: ad29b9b3-a49d-4f75-9c32-d4151df2e4e0
11:49:38 AM: statsd:
11:49:38 AM: host: datadog-agent
11:49:38 AM: port: 8125
11:49:38 AM: testOpts:
11:49:38 AM: silentLingeringProcesses: β€˜β€™
11:49:38 AM: ​
11:49:38 AM: ❯ Current directory
11:49:38 AM: /opt/build/repo
11:49:38 AM: ​
11:49:38 AM: ❯ Config file
11:49:38 AM: No config file was defined: using default values.
11:49:38 AM: ​
11:49:38 AM: ❯ Resolved config
11:49:38 AM: build:
11:49:38 AM: command: hugo_0.19
11:49:38 AM: commandOrigin: ui
11:49:38 AM: environment:
11:49:38 AM: - NETLIFY_BUILD_DEBUG
11:49:38 AM: - SITE_RECAPTCHA_KEY
11:49:38 AM: - SITE_RECAPTCHA_SECRET
11:49:38 AM: publish: /opt/build/repo/public
11:49:38 AM: publishOrigin: ui
11:49:38 AM: ​
11:49:38 AM: ❯ Context
11:49:38 AM: production
11:49:38 AM: ​
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: 1. Build command from Netlify app
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: ​
11:49:38 AM: $ hugo_0.19
11:49:38 AM: bash: hugo_0.19: command not found
11:49:38 AM: ​
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: β€œbuild.command” failed
11:49:38 AM: ────────────────────────────────────────────────────────────────
11:49:38 AM: ​
11:49:38 AM: Error message
11:49:38 AM: Command failed with exit code 127: hugo_0.19
11:49:38 AM: ​
11:49:38 AM: Error location
11:49:38 AM: In Build command from Netlify app:
11:49:38 AM: hugo_0.19
11:49:38 AM: ​
11:49:38 AM: Resolved config
11:49:38 AM: build:
11:49:38 AM: command: hugo_0.19
11:49:38 AM: commandOrigin: ui
11:49:38 AM: environment:
11:49:38 AM: - NETLIFY_BUILD_DEBUG
11:49:38 AM: - SITE_RECAPTCHA_KEY
11:49:38 AM: - SITE_RECAPTCHA_SECRET
11:49:38 AM: publish: /opt/build/repo/public
11:49:38 AM: publishOrigin: ui
11:49:39 AM: Caching artifacts
11:49:39 AM: Started saving build plugins
11:49:39 AM: Finished saving build plugins
11:49:39 AM: Started saving pip cache
11:49:39 AM: Finished saving pip cache
11:49:39 AM: Started saving emacs cask dependencies
11:49:39 AM: Finished saving emacs cask dependencies
11:49:39 AM: Started saving maven dependencies
11:49:39 AM: Finished saving maven dependencies
11:49:39 AM: Started saving boot dependencies
11:49:39 AM: Finished saving boot dependencies
11:49:39 AM: Started saving rust rustup cache
11:49:39 AM: Finished saving rust rustup cache
11:49:39 AM: Started saving go dependencies
11:49:39 AM: Finished saving go dependencies
11:49:41 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:49:41 AM: Creating deploy upload records
11:49:41 AM: Failing build: Failed to build site
11:49:41 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
11:49:41 AM: Finished processing build request in 11.556130377s

Welcome to the forums @sp_ppl

It appears your git repository has no package.json, so the build system doesn’t know what packages to install in order to build your site.

Once you have this, you would use npm run build to run the build script in the package.json (or yarn build if you use yarn.)

Edit: Information above is quite possibly irrelevant to this issue.

thanks @coelmay for the super-rapid reply!

I know this may not exactly be directly netlify-related but can you tell me how I go about adding a package.json to my githib repository and possibly what it should contain?

or if not where I should look for support/guidance on how to create the necessary package.json so the build will function correctly again (wondering how the build ever functioned correctly without a package.json unless this is something that has become a requirement more recently? don’t think anything would have been deleted from the repository…)

This looks like a Hugo website and it might not need any package.json unless you’re using Node Modules.

You simply need to set the build command to hugo instead of hugo_0.19. It should work fine. Do you have a build log where it doesn’t?

1 Like

Apologies @sp_ppl, after reading the Hugo on Netlify docs, I may have lead you down the wrong path.

Have you added a HUGO_VERSION environment variable?

And this.

1 Like

Thanks @hrishikesh and again to coelmay for the update.

In the meantime, had been browsing around in the Hugo on Netlify docs myself and can see that Hugo has come on a long way since my last successful build.

In line with the advice on Hugo on Netlify docs and the advice from both of you in the posts above, I have tried

  • adding a HUGO_VERSION environment variable for 0.83 under Build & Deploy
  • creating a netlify.toml file with the lines:
    [context.deploy-preview.environment]
    HUGO_VERSION = β€œ0.83.1”
    at the root of my github repository
    AND
  • changing the Build command in the deploy settings to hugo

but I’m still getting the error

β€œbuild.command” failed
Error message
Command failed with exit code 255: hugo

Here’s the full log of that latest failed build:

1:07:59 PM: Build ready to start
1:08:01 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
1:08:01 PM: build-image tag: v4.3.0
1:08:01 PM: buildbot version: fd60e21d56897195475b3dbb3e1c495894eb873c
1:08:01 PM: Fetching cached dependencies
1:08:01 PM: Failed to fetch cache, continuing with build
1:08:01 PM: Starting to prepare the repo for build
1:08:02 PM: No cached dependencies found. Cloning fresh repo
1:08:02 PM: git clone GitHub - praetoriuspl/ppl-site
1:08:04 PM: Preparing Git Reference refs/heads/master
1:08:05 PM: Parsing package.json dependencies
1:08:06 PM:
​
❯ Initial build environment
baseRelDir: true
branch: master
context: production
cwd: /opt/build/repo
featureFlags:
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: ad29b9b3-a49d-4f75-9c32-d4151df2e4e0
​
❯ UI build settings
baseRelDir: true
build:
command: hugo
environment:
- HUGO_VERSION
- NETLIFY_BUILD_DEBUG
- SITE_RECAPTCHA_KEY
- SITE_RECAPTCHA_SECRET
publish: public
​
❯ Resolved build environment
branch: master
buildDir: /opt/build/repo
configPath: /opt/build/repo/netlify.toml
context: production
env:
​
❯ Resolved config
build:
command: hugo
commandOrigin: ui
environment:
- HUGO_VERSION
- NETLIFY_BUILD_DEBUG
- SITE_RECAPTCHA_KEY
- SITE_RECAPTCHA_SECRET
publish: /opt/build/repo/public
publishOrigin: ui

1:08:06 PM: Starting build script
1:08:06 PM: Installing dependencies
1:08:06 PM: Python version set to 2.7
1:08:07 PM: Downloading and installing node v16.8.0…
1:08:07 PM: Downloading https://nodejs.org/dist/v16.8.0/node-v16.8.0-linux-x64.tar.xz…
1:08:07 PM: Computing checksum with sha256sum
1:08:07 PM: Checksums matched!
1:08:10 PM: Now using node v16.8.0 (npm v7.21.0)
1:08:11 PM: Started restoring cached build plugins
1:08:11 PM: Finished restoring cached build plugins
1:08:11 PM: Attempting ruby version 2.7.2, read from environment
1:08:12 PM: Using ruby version 2.7.2
1:08:12 PM: Using PHP version 8.0
1:08:12 PM: Installing Hugo 0.83.1
1:08:13 PM: hugo v0.83.1-5AFE0A57+extended linux/amd64 BuildDate=2021-05-02T14:38:05Z VendorInfo=gohugoio
1:08:13 PM: Started restoring cached go cache
1:08:13 PM: Finished restoring cached go cache
1:08:13 PM: go version go1.16.5 linux/amd64
1:08:13 PM: go version go1.16.5 linux/amd64
1:08:13 PM: Installing missing commands
1:08:13 PM: Verify run directory
1:08:15 PM: ​
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: Netlify Build
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: ​
1:08:15 PM: ❯ Version
1:08:15 PM: @netlify/build 18.7.2
1:08:15 PM: ​
1:08:15 PM: ❯ Flags
1:08:15 PM: apiHost: api.netlify.com
1:08:15 PM: baseRelDir: true
1:08:15 PM: branch: master
1:08:15 PM: buildId: 612e0d8f292ce7e22be89b62
1:08:15 PM: buildbotServerSocket: /tmp/netlify-buildbot-socket
1:08:15 PM: cacheDir: /opt/build/cache
1:08:15 PM: cachedConfigPath: /tmp/netlify_config.json
1:08:15 PM: context: production
1:08:15 PM: cwd: /opt/build/repo
1:08:15 PM: deployId: 612e0d8f292ce7e22be89b64
1:08:15 PM: featureFlags:
1:08:15 PM: - zisiEsbuildDynamicImports
1:08:15 PM: framework: hugo
1:08:15 PM: functionsDistDir: /tmp/zisi-612e0d8f292ce7e22be89b64
1:08:15 PM: mode: buildbot
1:08:15 PM: nodePath: /opt/buildhome/.nvm/versions/node/v16.8.0/bin/node
1:08:15 PM: repositoryRoot: /opt/build/repo
1:08:15 PM: saveConfig: true
1:08:15 PM: sendStatus: true
1:08:15 PM: siteId: ad29b9b3-a49d-4f75-9c32-d4151df2e4e0
1:08:15 PM: statsd:
1:08:15 PM: host: datadog-agent
1:08:15 PM: port: 8125
1:08:15 PM: testOpts:
1:08:15 PM: silentLingeringProcesses: β€˜β€™
1:08:15 PM: ​
1:08:15 PM: ❯ Current directory
1:08:15 PM: /opt/build/repo
1:08:15 PM: ​
1:08:15 PM: ❯ Config file
1:08:15 PM: /opt/build/repo/netlify.toml
1:08:15 PM: ​
1:08:15 PM: ❯ Resolved config
1:08:15 PM: build:
1:08:15 PM: command: hugo
1:08:15 PM: commandOrigin: ui
1:08:15 PM: environment:
1:08:15 PM: - HUGO_VERSION
1:08:15 PM: - NETLIFY_BUILD_DEBUG
1:08:15 PM: - SITE_RECAPTCHA_KEY
1:08:15 PM: - SITE_RECAPTCHA_SECRET
1:08:15 PM: publish: /opt/build/repo/public
1:08:15 PM: publishOrigin: ui
1:08:15 PM: ​
1:08:15 PM: ❯ Context
1:08:15 PM: production
1:08:15 PM: ​
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: 1. Build command from Netlify app
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: ​
1:08:15 PM: $ hugo
1:08:15 PM: Total in 0 ms
1:08:15 PM: Error: β€œ/opt/build/repo/config.toml:54:1”: unmarshal failed: Near line 54 (last key parsed β€˜params.services’): expected a top-level item to end with a newline, comment, or EOF, but got β€˜v’ instead
1:08:15 PM: ​
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: β€œbuild.command” failed
1:08:15 PM: ────────────────────────────────────────────────────────────────
1:08:15 PM: ​
1:08:15 PM: Error message
1:08:15 PM: Command failed with exit code 255: hugo
1:08:15 PM: ​
1:08:15 PM: Error location
1:08:15 PM: In Build command from Netlify app:
1:08:15 PM: hugo
1:08:15 PM: ​
1:08:15 PM: Resolved config
1:08:15 PM: build:
1:08:15 PM: command: hugo
1:08:15 PM: commandOrigin: ui
1:08:15 PM: environment:
1:08:15 PM: - HUGO_VERSION
1:08:15 PM: - NETLIFY_BUILD_DEBUG
1:08:15 PM: - SITE_RECAPTCHA_KEY
1:08:15 PM: - SITE_RECAPTCHA_SECRET
1:08:15 PM: publish: /opt/build/repo/public
1:08:15 PM: publishOrigin: ui
1:08:15 PM: Caching artifacts
1:08:15 PM: Started saving build plugins
1:08:15 PM: Finished saving build plugins
1:08:15 PM: Started saving pip cache
1:08:15 PM: Finished saving pip cache
1:08:15 PM: Started saving emacs cask dependencies
1:08:15 PM: Finished saving emacs cask dependencies
1:08:15 PM: Started saving maven dependencies
1:08:15 PM: Finished saving maven dependencies
1:08:15 PM: Started saving boot dependencies
1:08:15 PM: Finished saving boot dependencies
1:08:15 PM: Started saving rust rustup cache
1:08:15 PM: Finished saving rust rustup cache
1:08:15 PM: Started saving go dependencies
1:08:15 PM: Finished saving go dependencies
1:08:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:08:18 PM: Creating deploy upload records
1:08:18 PM: Failing build: Failed to build site
1:08:18 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
1:08:18 PM: Finished processing build request in 16.743261121s

This is the line

  enable = false video = true

possibly should look like

  enable = false
  video = true
1 Like

Thanks @coelmay that was it.

Possibly my bad from a rogue previous edit of the config file on my part :-/

The site is building again successfully now! :slight_smile:

Thanks once again to both of you for your help and for taking the time out to help a newbie!

1 Like