Failed to deploy website: Command failed with exit code 255

Hi, the issue is really driving me crazy.

10:17:58 AM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
10:17:58 AM: build-image tag: v4.16.3
10:17:58 AM: buildbot version: 0d92ba804851e1768a79721ec5ad312cd15c4ac9
10:17:58 AM: Fetching cached dependencies
10:17:58 AM: Failed to fetch cache, continuing with build
10:17:58 AM: Starting to prepare the repo for build
10:17:59 AM: No cached dependencies found. Cloning fresh repo
10:17:59 AM: git clone --filter=blob:none git@github.com:Cong902/mylab_jlc
10:18:02 AM: Preparing Git Reference refs/heads/main
10:18:04 AM: Parsing package.json dependencies
10:18:04 AM: Starting build script
10:18:05 AM: Installing dependencies
10:18:05 AM: Python version set to 2.7
10:18:05 AM: Downloading and installing node v12.18.0...
10:18:05 AM: Downloading https://nodejs.org/dist/v12.18.0/node-v12.18.0-linux-x64.tar.xz...
10:18:06 AM: Computing checksum with sha256sum
10:18:06 AM: Checksums matched!
10:18:07 AM: Now using node v12.18.0 (npm v6.14.4)
10:18:07 AM: Started restoring cached build plugins
10:18:07 AM: Finished restoring cached build plugins
10:18:08 AM: Attempting Ruby version 2.7.2, read from environment
10:18:08 AM: Using Ruby version 2.7.2
10:18:08 AM: Using PHP version 8.0
10:18:08 AM: Installing Hugo 0.97.3
10:18:10 AM: hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4+extended linux/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
10:18:10 AM: Started restoring cached go cache
10:18:10 AM: Finished restoring cached go cache
10:18:10 AM: Installing Go version 1.14.4 (requested 1.14.4)
10:18:14 AM: unset GOOS;
10:18:14 AM: unset GOARCH;
10:18:14 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64';
10:18:14 AM: export PATH="/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64/bin:${PATH}";
10:18:14 AM: go version >&2;
10:18:14 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.14.4.linux.amd64.env"
10:18:14 AM: go version go1.14.4 linux/amd64
10:18:14 AM: Detected 0 framework(s)
10:18:14 AM: Installing missing commands
10:18:14 AM: Verify run directory
10:18:14 AM: Section completed: initializing
10:18:15 AM: ​
10:18:15 AM:   Netlify Build                                                 
10:18:15 AM: ────────────────────────────────────────────────────────────────
10:18:15 AM: ​
10:18:15 AM: ❯ Version
10:18:15 AM:   @netlify/build 29.4.1
10:18:15 AM: ​
10:18:15 AM: ❯ Flags
10:18:15 AM:   baseRelDir: true
10:18:15 AM:   buildId: 63be1c555a2b5e0008acacdb
10:18:15 AM:   deployId: 63be1c555a2b5e0008acacdd
10:18:15 AM: ​
10:18:15 AM: ❯ Current directory
10:18:15 AM:   /opt/build/repo
10:18:15 AM: ​
10:18:15 AM: ❯ Config file
10:18:15 AM:   /opt/build/repo/netlify.toml
10:18:15 AM: ​
10:18:15 AM: ❯ Context
10:18:15 AM:   production
10:18:15 AM: ​
10:18:15 AM: ❯ Installing plugins
10:18:15 AM:    - netlify-plugin-hugo-cache-resources@0.2.1
10:18:17 AM: ​
10:18:17 AM: ❯ Loading plugins
10:18:17 AM:    - netlify-plugin-hugo-cache-resources@0.2.1 from netlify.toml
10:18:18 AM: ​
10:18:18 AM:   1. netlify-plugin-hugo-cache-resources (onPreBuild event)     
10:18:18 AM: ────────────────────────────────────────────────────────────────
10:18:18 AM: ​
10:18:18 AM: Checking if resources exist at "resources"
10:18:18 AM: No cache found for resources folder
10:18:18 AM: ​
10:18:18 AM: (netlify-plugin-hugo-cache-resources onPreBuild completed in 8ms)
10:18:18 AM: ​
10:18:18 AM:   2. build.command from netlify.toml                            
10:18:18 AM: ────────────────────────────────────────────────────────────────
10:18:18 AM: ​
10:18:18 AM: $ hugo --gc --minify -b $URL
10:18:20 AM: hugo: collected modules in 1430 ms
10:18:20 AM: Start building sites …
10:18:20 AM: hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4+extended linux/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
10:18:20 AM: WARN 2023/01/11 02:18:20 .Path when the page is backed by a file is deprecated and will be removed in a future release. We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct similar to the one below:
10:18:20 AM:   {{ $path := "" }}
10:18:20 AM:   {{ with .File }}
10:18:20 AM: 	{{ $path = .Path }}
10:18:20 AM:   {{ else }}
10:18:20 AM: 	{{ $path = .Path }}
10:18:20 AM:   {{ end }}
10:18:20 AM: Re-run Hugo with the flag --panicOnWarning to get a better error message.
10:18:20 AM: ERROR 2023/01/11 02:18:20 render of "page" failed: execute of template failed: template: _default/single.html:5:3: executing "_default/single.html" at <partial "site_head" .>: error calling partial: "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy@v0.0.0-20210526223849-81ba17522966/layouts/partials/site_head.html:177:13": execute of template failed: template: partials/site_head.html:177:13: executing "partials/site_head.html" at <getenv "WC_POST_CSS">: error calling getenv: access denied: "WC_POST_CSS" is not whitelisted in policy "security.funcs.getenv"; the current security configuration is:
10:18:20 AM: [security]
10:18:20 AM:   enableInlineShortcodes = false
10:18:20 AM:   [security.exec]
10:18:20 AM:     allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
10:18:20 AM:     osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
10:18:20 AM:   [security.funcs]
10:18:20 AM:     getenv = ['^HUGO_']
10:18:20 AM:   [security.http]
10:18:20 AM:     methods = ['(?i)GET|POST']
10:18:20 AM:     urls = ['.*']
10:18:20 AM: ERROR 2023/01/11 02:18:20 render of "page" failed: execute of template failed: template: publication/single.html:5:3: executing "publication/single.html" at <partial "site_head" .>: error calling partial: "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy@v0.0.0-20210526223849-81ba17522966/layouts/partials/site_head.html:177:13": execute of template failed: template: partials/site_head.html:177:13: executing "partials/site_head.html" at <getenv "WC_POST_CSS">: error calling getenv: access denied: "WC_POST_CSS" is not whitelisted in policy "security.funcs.getenv"; the current security configuration is:
10:18:20 AM: [security]
10:18:20 AM:   enableInlineShortcodes = false
10:18:20 AM:   [security.exec]
10:18:20 AM:     allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
10:18:20 AM:     osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
10:18:20 AM:   [security.funcs]
10:18:20 AM:     getenv = ['^HUGO_']
10:18:20 AM:   [security.http]
10:18:20 AM:     methods = ['(?i)GET|POST']
10:18:20 AM:     urls = ['.*']
10:18:20 AM: ERROR 2023/01/11 02:18:20 render of "page" failed: execute of template failed: template: publication/single.html:5:3: executing "publication/single.html" at <partial "site_head" .>: error calling partial: "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy@v0.0.0-20210526223849-81ba17522966/layouts/partials/site_head.html:177:13": execute of template failed: template: partials/site_head.html:177:13: executing "partials/site_head.html" at <getenv "WC_POST_CSS">: error calling getenv: access denied: "WC_POST_CSS" is not whitelisted in policy "security.funcs.getenv"; the current security configuration is:
10:18:20 AM: [security]
10:18:20 AM:   enableInlineShortcodes = false
10:18:20 AM:   [security.exec]
10:18:20 AM:     allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
10:18:20 AM:     osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
10:18:20 AM:   [security.funcs]
10:18:20 AM:     getenv = ['^HUGO_']
10:18:20 AM:   [security.http]
10:18:20 AM:     methods = ['(?i)GET|POST']
10:18:20 AM:     urls = ['.*']
10:18:20 AM: ERROR 2023/01/11 02:18:20 render of "page" failed: execute of template failed: template: widget_page/single.html:5:3: executing "widget_page/single.html" at <partial "site_head" .>: error calling partial: "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy@v0.0.0-20210526223849-81ba17522966/layouts/partials/site_head.html:177:13": execute of template failed: template: partials/site_head.html:177:13: executing "partials/site_head.html" at <getenv "WC_POST_CSS">: error calling getenv: access denied: "WC_POST_CSS" is not whitelisted in policy "security.funcs.getenv"; the current security configuration is:
10:18:20 AM: [security]
10:18:20 AM:   enableInlineShortcodes = false
10:18:20 AM:   [security.exec]
10:18:20 AM:     allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
10:18:22 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:18:20 AM:     osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
10:18:20 AM:   [security.funcs]
10:18:20 AM:     getenv = ['^HUGO_']
10:18:20 AM:   [security.http]
10:18:20 AM:     methods = ['(?i)GET|POST']
10:18:20 AM:     urls = ['.*']
10:18:20 AM: Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:5:3: executing "_default/single.html" at <partial "site_head" .>: error calling partial: "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy@v0.0.0-20210526223849-81ba17522966/layouts/partials/site_head.html:177:13": execute of template failed: template: partials/site_head.html:177:13: executing "partials/site_head.html" at <getenv "WC_POST_CSS">: error calling getenv: access denied: "WC_POST_CSS" is not whitelisted in policy "security.funcs.getenv"; the current security configuration is:
10:18:20 AM: [security]
10:18:20 AM:   enableInlineShortcodes = false
10:18:20 AM:   [security.exec]
10:18:20 AM:     allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
10:18:20 AM:     osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
10:18:20 AM:   [security.funcs]
10:18:20 AM:     getenv = ['^HUGO_']
10:18:20 AM:   [security.http]
10:18:20 AM:     methods = ['(?i)GET|POST']
10:18:20 AM:     urls = ['.*']
10:18:20 AM: Total in 1873 ms
10:18:20 AM: ​
10:18:20 AM:   "build.command" failed                                        
10:18:20 AM: ────────────────────────────────────────────────────────────────
10:18:20 AM: ​
10:18:20 AM:   Error message
10:18:20 AM:   Command failed with exit code 255: hugo --gc --minify -b $URL (https://ntl.fyi/exit-code-255)
10:18:20 AM: ​
10:18:20 AM:   Error location
10:18:20 AM:   In build.command from netlify.toml:
10:18:20 AM:   hugo --gc --minify -b $URL
10:18:20 AM: ​
10:18:20 AM:   Resolved config
10:18:20 AM:   build:
10:18:20 AM:     command: hugo --gc --minify -b $URL
10:18:20 AM:     commandOrigin: config
10:18:20 AM:     environment:
10:18:20 AM:       - HUGO_VERSION
10:18:20 AM:       - NETLIFY_GRAPH_TOKEN
10:18:20 AM:       - ONEGRAPH_AUTHLIFY_TOKEN
10:18:20 AM:       - HUGO_ENABLEGITINFO
10:18:20 AM:       - HUGO_ENV
10:18:20 AM:     publish: /opt/build/repo/public
10:18:20 AM:     publishOrigin: config
10:18:20 AM:   plugins:
10:18:20 AM:     - inputs:
10:18:20 AM:         debug: true
10:18:20 AM:       origin: config
10:18:20 AM:       package: netlify-plugin-hugo-cache-resources
10:18:20 AM: Caching artifacts
10:18:20 AM: Started saving build plugins
10:18:20 AM: Finished saving build plugins
10:18:21 AM: Started saving pip cache
10:18:21 AM: Finished saving pip cache
10:18:21 AM: Started saving emacs cask dependencies
10:18:21 AM: Finished saving emacs cask dependencies
10:18:21 AM: Started saving maven dependencies
10:18:21 AM: Finished saving maven dependencies
10:18:21 AM: Started saving boot dependencies
10:18:21 AM: Finished saving boot dependencies
10:18:21 AM: Started saving rust rustup cache
10:18:21 AM: Finished saving rust rustup cache
10:18:21 AM: Started saving go dependencies
10:18:21 AM: Finished saving go dependencies
10:18:21 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:18:21 AM: Failing build: Failed to build site
10:18:22 AM: Finished processing build request in 23.712966199s

The last thing I have done is that editing one author’s ‘index.md’ deployed perfectly, and after that non can be deployed.

Any help would be appreciated.

Hi @Cong902 :wave:t6:,

Welcome to the forums! Thanks for reaching our sorry to hear your build has been failing.

Please try the following and let me know if it works.

npm install
npm run make:prepare
HUGO_VERSION= (latest version of HUGO) npm run serve

hugo-cli dependency will shadow Netlify buildbot Hugo version based on whatever is specified in HUGO_VERSION and will do it with the non extended version.

The Hugo version will be downloaded under node_modules hence, cached for future builds.

Solution - remove hugo-cli dependency or use hugo-extended.

Hi @SamO ,

Thanks a lot for your help! But as I am new with HUGO, I could not understand where to fix the problem. Could you give some more specific guidance?

I feel that line is fairly clear about the error. You need to change getenv = ['^HUGO_'] to getenv = ['^HUGO_', '^WC_']