Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hugo mod tidy panics with Go 1.24+ tool directive in go.mod #14783

@mikebaum

Description

@mikebaum

Description

hugo mod tidy panics with an index-out-of-range error when go.mod contains a tool block (introduced in Go 1.24).

Hugo Version

Tested on v0.156.0 and v0.160.1. Also confirmed the bug exists on current master by reading the source.

Go Version

go version go1.26.0 darwin/arm64

To Reproduce

  1. Create a Hugo module project with a go.mod that includes a tool block:
module example.com/mysite

go 1.26.0

require (
    github.com/imfing/hextra v0.12.1 // indirect
)

tool (
    github.com/gohugoio/hugo
)
  1. Run hugo mod tidy

Expected Behaviour

hugo mod tidy completes successfully, ignoring the tool block.

Actual Behaviour

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/gohugoio/hugo/modules.(*Client).rewriteGoModRewrite(...)
        modules/client.go:728 +0x428

Does this issue reproduce with the latest release?

Yes

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions