Hugo: command not found

Hi,

I can’t build my site with hugo anymore: I’ve been building it for years at netlify, and it suddenly stopped working. The main error message is bash: line 1: hugo: command not found.

Init log:

3:13:53 PM: build-image version: 9a361c83c6a43010ba0aa3ea38214accc0223b2c (noble)
3:13:53 PM: buildbot version: 9a4374dc9e2c1cbd2a152e441d69a3a6d7e12511
3:13:59 PM: Fetching cached dependencies
3:13:59 PM: Failed to fetch cache, continuing with build
3:13:59 PM: Starting to prepare the repo for build
3:13:59 PM: No cached dependencies found. Cloning fresh repo
3:13:59 PM: git clone --filter=blob:none https://github.com/jpcaruana/jp.caruana.fr
3:14:00 PM: Preparing Git Reference refs/heads/test-build
3:14:03 PM: Custom build command detected. Proceeding with the specified command: 'hugo --gc --minify --buildFuture'
3:14:04 PM: Starting to install dependencies
3:14:04 PM: Python version set to 3.13.2
3:14:05 PM: mise ruby@2.6.2      install
3:14:05 PM: mise ruby@2.6.2      ruby-build
3:14:05 PM: mise ruby@2.6.2      ==> Downloading openssl-1.1.1w.tar.gz...
3:14:05 PM: mise ruby@2.6.2      -> curl -q -fL -o openssl-1.1.1w.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
3:14:05 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
3:14:05 PM:                                  Dload  Upload   Total   Spent    Left  Speed
3:14:05 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
3:14:05 PM: 100 9661k  100 9661k    0     0  86.9M      0 --:--:-- --:--:-- --:--:-- 87.3M
3:14:06 PM: mise ruby@2.6.2      ==> Installing openssl-1.1.1w...
3:14:06 PM: mise ruby@2.6.2      -> ./config "--prefix=$HOME/.local/share/mise/installs/ruby/2.6.2/openssl" "--openssldir=$HOME/.local/share/mise/installs/ruby/2.6.2/openssl/ssl" --libdir=lib zlib-dynamic no-ssl3 shared "-Wl,-rpath,$HOME/.local/share/mise/installs/ruby/2.6.2/openssl/lib"
3:14:08 PM: mise ruby@2.6.2      -> make -j 32
3:14:57 PM: mise ruby@2.6.2      -> make install_sw install_ssldirs
3:14:58 PM: mise ruby@2.6.2      ==> Installed openssl-1.1.1w to /opt/buildhome/.local/share/mise/installs/ruby/2.6.2
3:14:58 PM: mise ruby@2.6.2      ==> Downloading ruby-2.6.2.tar.bz2...
3:14:58 PM: mise ruby@2.6.2      -> curl -q -fL -o ruby-2.6.2.tar.bz2 https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.2.tar.bz2
3:14:58 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
3:14:58 PM:                                  Dload  Upload   Total   Spent    Left  Speed
3:14:58 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
3:14:58 PM: 100 13.9M  100 13.9M    0     0  48.9M      0 --:--:-- --:--:-- --:--:-- 49.1M
3:15:00 PM: mise ruby@2.6.2      ==> Installing ruby-2.6.2...
3:15:00 PM: WARNING: ruby-2.6.2 is past its end of life and is now unsupported.
3:15:00 PM: It no longer receives bug fixes or critical security updates.
3:15:00 PM: mise ruby@2.6.2      -> ./configure "--prefix=$HOME/.local/share/mise/installs/ruby/2.6.2" "--with-openssl-dir=$HOME/.local/share/mise/installs/ruby/2.6.2/openssl" --enable-shared --with-ext=openssl,psych,+
3:15:21 PM: mise ruby@2.6.2      -> make -j 32
3:17:11 PM: mise ruby@2.6.2      -> make install
3:17:17 PM: mise ruby@2.6.2      ==> Installed ruby-2.6.2 to /opt/buildhome/.local/share/mise/installs/ruby/2.6.2
3:17:21 PM: mise ruby@2.6.2    ✓ installed
3:17:21 PM: Ruby version set to 2.6.2
3:17:21 PM: mise go@1.12         install
3:17:21 PM: mise go@1.12         download go1.12.linux-amd64.tar.gz
3:17:23 PM: mise go@1.12         checksum go1.12.linux-amd64.tar.gz
3:17:23 PM: mise go@1.12         extract go1.12.linux-amd64.tar.gz
3:17:25 PM: mise go@1.12         go version
3:17:25 PM: mise go@1.12         go version go1.12 linux/amd64
3:17:25 PM: mise go@1.12       ✓ installed
3:17:25 PM: Go version set to 1.12
3:17:26 PM: Using PHP version 8.3
3:17:27 PM: v22.14.0 is already installed.
3:17:28 PM: Now using node v22.14.0 (npm v10.9.2)
3:17:28 PM: Enabling Node.js Corepack
3:17:28 PM: Started restoring cached build plugins
3:17:28 PM: Finished restoring cached build plugins
3:17:28 PM: Successfully installed dependencies
3:17:28 PM: Starting build script
3:17:29 PM: Detected 1 framework(s)
3:17:29 PM: "hugo" at version "unknown"
3:17:29 PM: Section completed: initializing

Build log:

3:17:30 PM: Netlify Build                                                 
3:17:30 PM: ────────────────────────────────────────────────────────────────
3:17:30 PM: ​
3:17:30 PM: ❯ Version
3:17:30 PM:   @netlify/build 29.59.2
3:17:30 PM: ​
3:17:30 PM: ❯ Flags
3:17:30 PM:   accountId: 5d1f5df2c88c68d5b8df3747
3:17:30 PM:   baseRelDir: true
3:17:30 PM:   buildId: 67d196912f842b0008d8e8be
3:17:30 PM:   deployId: 67d196912f842b0008d8e8c0
3:17:30 PM: ​
3:17:30 PM: ❯ Current directory
3:17:30 PM:   /opt/build/repo
3:17:30 PM: ​
3:17:30 PM: ❯ Config file
3:17:30 PM:   /opt/build/repo/netlify.toml
3:17:30 PM: ​
3:17:30 PM: ❯ Context
3:17:30 PM:   branch-deploy
3:17:30 PM: ​
3:17:30 PM: ❯ Installing plugins
3:17:30 PM:    - netlify-plugin-hugo-cache-resources@0.2.1
3:17:32 PM: ​
3:17:32 PM: ❯ Loading plugins
3:17:32 PM:    - netlify-plugin-hugo-cache-resources@0.2.1 from Netlify app
3:17:33 PM: Checking if resources exist at "resources"
3:17:33 PM: No cache found for resources folder
3:17:33 PM: ​
3:17:33 PM: build.command from netlify.toml                               
3:17:33 PM: ────────────────────────────────────────────────────────────────
3:17:33 PM: ​
3:17:33 PM: $ hugo --gc --minify --buildFuture
3:17:33 PM: bash: line 1: hugo: command not found
3:17:34 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:17:34 PM: ​
3:17:34 PM: "build.command" failed                                        
3:17:34 PM: ────────────────────────────────────────────────────────────────
3:17:34 PM: ​
3:17:34 PM:   Error message
3:17:34 PM:   Command failed with exit code 127: hugo --gc --minify --buildFuture (https://ntl.fyi/exit-code-127)
3:17:34 PM: ​
3:17:34 PM:   Error location
3:17:34 PM:   In build.command from netlify.toml:
3:17:34 PM:   hugo --gc --minify --buildFuture
3:17:34 PM: ​
3:17:34 PM:   Resolved config
3:17:34 PM:   build:
3:17:34 PM:     base: /opt/build/repo
3:17:34 PM:     command: hugo --gc --minify --buildFuture
3:17:34 PM:     commandOrigin: config
3:17:34 PM:     publish: /opt/build/repo/public
3:17:34 PM:     publishOrigin: config
3:17:34 PM:   headers:
3:17:34 PM:     - for: /.well-known/openpgpkey/*
      values:
        Access-Control-Allow-Origin: '*'
  headersOrigin: config
  plugins:
    - inputs: {}
      origin: ui
      package: netlify-plugin-hugo-cache-resources
  redirects:
    - from: /.well-known/host-meta*
      status: 302
      to: https://fed.brid.gy/.well-known/host-meta:splat
    - from: /.well-known/webfinger*
      status: 302
      to: https://fed.brid.gy/.well-known/webfinger
  redirectsOrigin: config
3:17:34 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:17:34 PM: Failing build: Failed to build site
3:17:35 PM: Finished processing build request in 3m41.568s

I have the feeling netlify tries to outsmart what I ask, my local folder looks like this:

.                     .git                  .well-known           archetypes            content               hugo.toml             netlify.toml          update_webmentions.py
..                    .gitignore            README.md             assets                data                  jp.caruana.fr.iml     resources             update_webmentions.sh
.DS_Store             .hugo_build.lock      _redirects            build                 github.py             layouts               static                upload.sh

It used to work great until recently.
Thank you for your insights!

My netlify.toml includes target hugo version:

[build]
  base = "."
  publish = "public/"
  command = "hugo --gc --minify --buildFuture"

[context.production.environment]
  HUGO_VERSION = "0.145.0"
  HUGO_ENV = "production"
  TZ = "Europe/Paris"

The init log says 3:17:29 PM: "hugo" at version "unknown"

I change my configuration:

[build.environment]
  HUGO_VERSION = "0.145.0"
  HUGO_ENV = "production"
  TZ = "Europe/Paris"

and it works.

I also remove any python related file so netlify doesn’t try to install python for nothing

Hi, @jpcaruana. Thank you for sharing your solution here. If there are other questions about this, please let us know.