Home
Support Forums

Unknown sub-command mod when building academic hugo theme after wowchemy upgrade

I have already outlined my problem at https://github.com/wowchemy/wowchemy-hugo-modules/issues/1921 but was redirected in discourse to the netlify community. TLDR: I want to upgrade hugo and use go modules for the academic template. Locally as well for a fresh template, it builds just fine. However, for the existing website, the hugo build command fails (with what I guess would be an incompatible go version). How can this be fixed?

the build log:

4:40:21 PM: Build ready to start
4:40:23 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
4:40:23 PM: build-image tag: v3.4.1
4:40:23 PM: buildbot version: cdc66b02d86506251d3343610a77385376c8c035
4:40:24 PM: Fetching cached dependencies
4:40:24 PM: Starting to download cache of 426.1MB
4:40:29 PM: Finished downloading cache in 5.277848568s
4:40:29 PM: Starting to extract cache
4:40:38 PM: Finished extracting cache in 9.345564016s
4:40:39 PM: Finished fetching cache in 14.891417821s
4:40:39 PM: Starting to prepare the repo for build
4:40:39 PM: Preparing Git Reference refs/heads/master
4:40:41 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify -b $URL' versus 'hugo' in the Netlify UI
4:40:42 PM: Starting build script
4:40:42 PM: Installing dependencies
4:40:42 PM: Python version set to 2.7
4:40:42 PM: Started restoring cached node version
4:40:45 PM: Finished restoring cached node version
4:40:46 PM: v8.17.0 is already installed.
4:40:46 PM: Now using node v8.17.0 (npm v6.13.4)
4:40:47 PM: Started restoring cached build plugins
4:40:47 PM: Finished restoring cached build plugins
4:40:47 PM: Attempting ruby version 2.3.6, read from environment
4:40:47 PM: Started restoring cached ruby version
4:40:47 PM: Finished restoring cached ruby version
4:40:49 PM: Using ruby version 2.3.6
4:40:50 PM: Successfully installed bundler-2.1.4
4:40:50 PM: 1 gem installed
4:40:50 PM: Using PHP version 5.6
4:40:50 PM: 5.2 is already installed.
4:40:50 PM: Using Swift version 5.2
4:40:50 PM: Installing Hugo 0.75.1
4:40:51 PM: Hugo Static Site Generator v0.75.1-A4A7BAB7/extended linux/amd64 BuildDate: 2020-09-15T06:57:20Z
4:40:51 PM: Started restoring cached go cache
4:40:53 PM: Finished restoring cached go cache
4:40:53 PM: Installing Go version 1.10
4:40:53 PM: unset GOOS;
4:40:53 PM: unset GOARCH;
4:40:53 PM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';
4:40:53 PM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}";
4:40:53 PM: go version >&2;
4:40:53 PM: export GIMME_ENV='/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env';
4:40:53 PM: go version go1.10 linux/amd64
4:40:53 PM: Installing missing commands
4:40:53 PM: Verify run directory
4:40:54 PM: ​
4:40:54 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
4:40:54 PM: β”‚        Netlify Build        β”‚
4:40:54 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
4:40:54 PM: ​
4:40:54 PM: ❯ Version
4:40:54 PM:   @netlify/build 5.0.3
4:40:54 PM: ​
4:40:54 PM: ❯ Flags
4:40:54 PM:   deployId: 5f9ae2652e3fab00092000e0
4:40:54 PM:   mode: buildbot
4:40:54 PM: ​
4:40:54 PM: ❯ Current directory
4:40:54 PM:   /opt/build/repo
4:40:54 PM: ​
4:40:54 PM: ❯ Config file
4:40:54 PM:   /opt/build/repo/netlify.toml
4:40:54 PM: ​
4:40:54 PM: ❯ Context
4:40:54 PM:   production
4:40:54 PM: ​
4:40:54 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
4:40:54 PM: β”‚ 1. build.command from netlify.toml β”‚
4:40:54 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
4:40:54 PM: ​
4:40:54 PM: $ hugo --gc --minify -b $URL
4:40:54 PM: go: unknown subcommand "mod"
4:40:54 PM: Run 'go help' for usage.
4:40:54 PM: Total in 18 ms
4:40:54 PM: Error: failed to download modules: go command failed: go: unknown subcommand "mod"
4:40:54 PM: Run 'go help' for usage.
4:40:54 PM: ​
4:40:54 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
4:40:54 PM: β”‚   "build.command" failed    β”‚
4:40:54 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
4:40:54 PM: ​
4:40:54 PM:   Error message
4:40:54 PM:   Command failed with exit code 255: hugo --gc --minify -b $URL
4:40:54 PM: ​
4:40:54 PM:   Error location
4:40:54 PM:   In build.command from netlify.toml:
4:40:54 PM:   hugo --gc --minify -b $URL
4:40:54 PM: ​
4:40:54 PM:   Resolved config
4:40:54 PM:   build:
4:40:54 PM:     command: hugo --gc --minify -b $URL
4:40:54 PM:     commandOrigin: config
4:40:54 PM:     environment:
4:40:54 PM:       - HUGO_VERSION
4:40:54 PM:       - HUGO_ENABLEGITINFO
4:40:54 PM:       - HUGO_ENV
4:40:54 PM:     publish: /opt/build/repo/public
4:40:54 PM:   headers:
4:40:54 PM:     - for: '*.webmanifest'
4:40:54 PM:       values:
4:40:54 PM:         Content-Type: application/manifest+json; charset=UTF-8
4:40:54 PM:     - for: index.xml
4:40:54 PM:       values:
4:40:54 PM:         Content-Type: application/rss+xml
4:40:54 PM: Caching artifacts
4:40:54 PM: Started saving build plugins
4:40:54 PM: Finished saving build plugins
4:40:54 PM: Started saving pip cache
4:40:54 PM: Finished saving pip cache
4:40:54 PM: Started saving emacs cask dependencies
4:40:54 PM: Finished saving emacs cask dependencies
4:40:54 PM: Started saving maven dependencies
4:40:54 PM: Finished saving maven dependencies
4:40:54 PM: Started saving boot dependencies
4:40:54 PM: Finished saving boot dependencies
4:40:54 PM: Started saving go dependencies
4:40:56 PM: Finished saving go dependencies
4:40:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:40:56 PM: Failing build: Failed to build site
4:40:56 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:40:56 PM: Finished processing build request in 32.371623566s
  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.

In fact:

4:40:53 PM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';

already looks like a problem - modules seem to be only available in a later version of go. Perhaps I just need to clear some cache?

After executing a clear cache & deploy on netlify:

5:37:15 PM: Started restoring cached go cache
5:37:15 PM: Finished restoring cached go cache
5:37:15 PM: Installing Go version 1.10

is still found in the logs and thus failing the build

https://wowchemy.com/docs/faq/#error-failed-to-download-modulesunknown-subcommand-mod is the solution i.e. forcing a specific newer go version in the environment variables

2 Likes

thank you for sharing your progress as you go along!