Build: Hugo-extended builds that previously successfully deployed now require explicit hugo-extended install

Created on 28 May 2020  Β·  7Comments  Β·  Source: netlify/build

Describe the bug
A user who was previously successfully deploying hugo-extended builds started seeing build failures due to scss handling errors:

4:35:55 PM: $ hugo --gc --minify --enableGitInfo --baseURL $URL --environment development
4:35:55 PM: DEBUG target={ platform: 'linux', arch: 'x64' }, hugo={ version: '0.71.0' }
4:35:55 PM: DEBUG searching executable at </opt/build/repo/node_modules/hugo-cli/tmp/hugo_0.71.0_linux_amd64>
4:35:55 PM: INFO hugo not found. Attempting to fetch it...
4:35:55 PM: DEBUG downloading archive from <https://github.com/gohugoio/hugo/releases/download/v0.71.0/hugo_0.71.0_Linux-64bit.tar.gz>
4:35:56 PM: INFO fetched hugo 0.71.0
4:35:56 PM: INFO extracting archive...
4:35:57 PM: DEBUG extracted archive to </opt/build/repo/node_modules/hugo-cli/tmp>
4:35:57 PM: INFO hugo available, let's go!
4:35:57 PM: Building sites …
4:37:57 PM: ERROR 2020/05/27 23:37:57 TOCSS: failed to transform "scss/main.scss" (text/x-scss): resource "scss/scss/main.scss_df0fcb6fcf7ac0465cc4f11d40f9fe96" not found in file cache
4:37:57 PM: Total in 120386 ms
4:37:57 PM: Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): resource "scss/scss/main.scss_e59e0ecc24dedce3dd5dba3ad899859c" not found in file cache

This line:
4:35:55 PM: DEBUG downloading archive from <https://github.com/gohugoio/hugo/releases/download/v0.71.0/hugo_0.71.0_Linux-64bit.tar.gz>
is the correct Hugo version number but it is not the extended version.

User said:

It looks like the new version of Netlify build looks for the hugo-extended npm package first and if it doesn't find it it'll fall back to the lesser version preventing the SCSS features of Hugo.

He fixed this issue by running npm install hugo-extended --save-dev, which previously was not required.

Deploy logs
Logs for the following are here (not public):

  • successful deploy before Build
  • failed deploy with Build
  • successful deploy with Build, after npm install hugo-extended

Additional context
The person who ran into this created a post in Hugo forums explaining: https://discourse.gohugo.io/t/netlify-build-error-255-tocss-troubleshooting/25887/5

bug

Most helpful comment

Update

Was able to reproduce locally in this branch https://github.com/erezrokah/hugo-coder/tree/chore/change_hugo_version by running:

npm install
npm run make:prepare
HUGO_VERSION=0.71.1 npm run serve

Underlying issue - 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.

hugo-extended acts similar to hugo-cli but with the extended version.

Solution

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

All 7 comments

Following up on this - looks like these logs are coming from an external dependency and not from Netlify build process: https://github.com/nikku/hugo-cli/blob/335be93184d20bcd457aea2617d06ad018824443/index.js#L178

If Hugo's version is missing Netlify installs the extended version as can be seen here:
https://app.netlify.com/sites/flamboyant-brahmagupta-d09f93/deploys/5edd05d8cd525f00080b784a
image

Once I added that dependency to my Hugo repo (this is repo that uses SCSS) I started getting those message as can be seen here:
https://app.netlify.com/sites/flamboyant-brahmagupta-d09f93/deploys/5edd0cf2c2fbad0008ad8da4
image

Though not getting the build failures yet.

Still not sure what had changed or why the npm install hugo-extended --save-dev fixes the build but will dig dipper.

Update

Was able to reproduce locally in this branch https://github.com/erezrokah/hugo-coder/tree/chore/change_hugo_version by running:

npm install
npm run make:prepare
HUGO_VERSION=0.71.1 npm run serve

Underlying issue - 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.

hugo-extended acts similar to hugo-cli but with the extended version.

Solution

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

@erezrokah Fantastic! thank you

Closing, please comment if relevant and we'll re-open

Hi Team,

I am getting the below build issue while deploying hugo theme on netifly. Any suggestions of what I am doing wrong as I am? Thanks in advance!

Regards,
Pranav

10:59:46 AM: Build ready to start
10:59:48 AM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
10:59:48 AM: build-image tag: v3.3.19
10:59:48 AM: buildbot version: 2cc7ea668a3e8f63326d15aab17e62cd1997fa2e
10:59:48 AM: Fetching cached dependencies
10:59:48 AM: Starting to download cache of 254.7KB
10:59:48 AM: Finished downloading cache in 68.636413ms
10:59:48 AM: Starting to extract cache
10:59:48 AM: Failed to fetch cache, continuing with build
10:59:48 AM: Starting to prepare the repo for build
10:59:48 AM: No cached dependencies found. Cloning fresh repo
10:59:48 AM: git clone https://github.com/Pranavbawa/portfolio2
10:59:49 AM: Preparing Git Reference refs/heads/master
10:59:51 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify' versus '"hugo --gc --minify"' in the Netlify UI
10:59:51 AM: Starting build script
10:59:51 AM: Installing dependencies
10:59:51 AM: Python version set to 2.7
10:59:52 AM: v12.18.0 is already installed.
10:59:52 AM: Now using node v12.18.0 (npm v6.14.4)
10:59:53 AM: Started restoring cached build plugins
10:59:53 AM: Finished restoring cached build plugins
10:59:53 AM: Attempting ruby version 2.7.1, read from environment
10:59:54 AM: Using ruby version 2.7.1
10:59:54 AM: Using PHP version 5.6
10:59:54 AM: 5.2 is already installed.
10:59:54 AM: Using Swift version 5.2
10:59:54 AM: Installing Hugo 0.55.0
10:59:56 AM: Hugo Static Site Generator v0.55.0-4333CC77F/extended linux/amd64 BuildDate: 2019-04-08T17:05:23Z
10:59:56 AM: Started restoring cached go cache
10:59:56 AM: Finished restoring cached go cache
10:59:56 AM: go version go1.14.4 linux/amd64
10:59:56 AM: go version go1.14.4 linux/amd64
10:59:56 AM: Installing missing commands
10:59:56 AM: Verify run directory
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚        Netlify Build        β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM: ❯ Version
10:59:57 AM:   @netlify/build 2.0.25
10:59:57 AM: ​
10:59:57 AM: ❯ Flags
10:59:57 AM:   deployId: 5f04b812b3afe565edb5fac0
10:59:57 AM:   mode: buildbot
10:59:57 AM: ​
10:59:57 AM: ❯ Current directory
10:59:57 AM:   /opt/build/repo
10:59:57 AM: ​
10:59:57 AM: ❯ Config file
10:59:57 AM:   /opt/build/repo/netlify.toml
10:59:57 AM: ​
10:59:57 AM: ❯ Context
10:59:57 AM:   production
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚ 1. build.command from netlify.toml β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM: $ hugo --gc --minify
10:59:57 AM: Building sites … Total in 1 ms
10:59:57 AM: Error: Error building site: open /opt/build/repo/content: no such file or directory
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚   "build.command" failed    β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM:   Error message
10:59:57 AM:   Command failed with exit code 255: hugo --gc --minify
10:59:57 AM: ​
10:59:57 AM:   Error location
10:59:57 AM:   In build.command from netlify.toml:
10:59:57 AM:   hugo --gc --minify
10:59:57 AM: ​
10:59:57 AM:   Resolved config
10:59:57 AM:   build:
10:59:57 AM:     command: hugo --gc --minify
10:59:57 AM:     commandOrigin: config
10:59:57 AM:     environment:
10:59:57 AM:       - HUGO_VERSION
10:59:57 AM:       - HUGO_ENV
10:59:57 AM:       - HUGO_ENABLEGITINFO
10:59:57 AM:     publish: /opt/build/repo/public
10:59:57 AM: Caching artifacts
10:59:57 AM: Started saving build plugins
10:59:57 AM: Finished saving build plugins
10:59:57 AM: Started saving pip cache
10:59:57 AM: Finished saving pip cache
10:59:57 AM: Started saving emacs cask dependencies
10:59:57 AM: Finished saving emacs cask dependencies
10:59:57 AM: Started saving maven dependencies
10:59:57 AM: Finished saving maven dependencies
10:59:57 AM: Started saving boot dependencies
10:59:57 AM: Finished saving boot dependencies
10:59:57 AM: Started saving go dependencies
10:59:57 AM: Finished saving go dependencies
11:00:00 AM: Error running command: Build script returned non-zero exit code: 1
11:00:00 AM: Failing build: Failed to build site
11:00:00 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
11:00:00 AM: Finished processing build request in 11.720149997s

Hi @Pranavbawa, as this doesn't seem to be related to the this issue I recommend asking in Netlify community:
https://community.netlify.com

Regardless, looks like your build command is failing Command failed with exit code 255: hugo --gc --minify. I would try running netlify build locally using Netlify CLI https://docs.netlify.com/cli/get-started/ to get more insights.

@erezrokah Will do as you advised. Thanks for the information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlengstorf picture jlengstorf  Β·  4Comments

phortonssf picture phortonssf  Β·  6Comments

ehmicky picture ehmicky  Β·  4Comments

Tom-Bonnike picture Tom-Bonnike  Β·  3Comments

DavidWells picture DavidWells  Β·  3Comments