Hugo modules working locally, but failng in Gitlab CI

Hello!

I’m working on splitting our corporate doc portal into modules. It perfectly works on my local machine (MacOS), but fails in Gitlab CI with image mhart/alpine-node:14.17

$ go version
go version go1.21.5 linux/amd64
$ ./hugo version
hugo v0.121.1-00b46fed8e47f7bb0a85d7cfc2d9f1356379b740 linux/amd64 BuildDate=2023-12-08T08:47:45Z VendorInfo=gohugoio
$ ./hugo mod get -u github.com/ratanoff/docs-platform
go: finding github.com/ratanoff/docs-platform latest
go: downloading github.com/ratanoff/docs-platform v0.0.0-20231226162903-dde71e156fdc
go: extracting github.com/ratanoff/docs-platform v0.0.0-20231226162903-dde71e156fdc
$ rm -rf ./public/*
$ ./hugo --config=config/main-config.toml,config/tags-config.toml,config/ru.toml
flag provided but not defined: -modcacherw
usage: go mod download [-json] [modules]
Run 'go help mod download' for details.
Total in 9 ms
Error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: flag provided but not defined: -modcacherw
usage: go mod download [-json] [modules]
Run 'go help mod download' for details.
 *errors.errorString
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

go.mod in “main” repo:

module gitlab.loc/documentation/xsolla-docs

go 1.21

config in “main” repo

...
[module]
[[module.imports]]
  path = "github.com/ratanoff/docs-platform"
...

Thanks in advance!

What is the Go version running on GitLab CI? That flag was introduced since Go 1.14, so I guessed the GitLab CI Go version is too old?

go version is latest - go1.21.5

After some investigation I have found, that this flag was added in Hugo v0.118.0 as non-optional, so downgrade to v0.117.0 solved the problem.

@bep anyway, how we can adopt it in v0.121.1 to use all benefits of the latest version?

I am unable to reproduce the problem using this simple Dockerfile based on the golang:alpine3.19 image:

# Base image
FROM golang:alpine3.19

# Working directory
WORKDIR /project

# Install Git
RUN apk update && \
    apk add git && \
    git config --system --add safe.directory /project && \
    git config --system --add core.quotepath false

# Intall Node.js
RUN apk add nodejs npm && \
    mkdir /.npm && \
    chmod 777 /.npm

# Install Hugo
RUN apk add --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community hugo
ENV HUGO_CACHEDIR="/cache"

This image contains:

  • hugo v0.121.1+extended
  • git 2.43.0
  • go 1.21.5
  • node v20.10.0
  • npm 10.2.5

So, the problem is with your image. Like @razon, I suspect you are not running Go 1.21 in your container.