Skip to content
Latchkey

Go "go install: version is required" - Fix Tool Installs in CI

Since Go 1.16, go install of a tool by path requires an explicit version suffix (@latest, @v1.2.3) when run outside a module. Installing a bare path with no version is rejected.

What this error means

A CI step fails with go install: version is required when current directory is not in a main module. It happens after upgrading Go, when an old go install <path> (no @version) stops working.

go output
go install: version is required when current directory is not in a main module
	try 'go install github.com/org/tool@latest' to install the latest version

Common causes

go install without an @version suffix

Modern Go requires go install path@version when outside a module. A legacy go install path no longer resolves a version on its own.

Running install outside any module

When the working directory has no go.mod, Go cannot infer a version from a module graph, so the explicit @version is mandatory.

How to fix it

Add an explicit version suffix

Pin the tool to a version (preferred) or use @latest.

Terminal
go install github.com/org/tool@v1.5.0
# or, to track the newest release
go install github.com/org/tool@latest

Install module-tracked tools from a tools.go

When the tool versions live in your module, install them at the versions go.mod pins.

Terminal
# inside the module, with the tool listed in tools.go
go install github.com/org/tool   # resolves the pinned version

How to prevent it

  • Always install tools with an explicit @version in CI.
  • Prefer pinned versions over @latest for reproducible builds.
  • Track generator/tool versions in a tools.go.

Frequently asked questions

What causes ""version is required""?
Modern Go requires go install path@version when outside a module. A legacy go install path no longer resolves a version on its own.
How do I fix "version is required"?
Pin the tool to a version (preferred) or use @latest.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card