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 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 versionCommon 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.
go install github.com/org/tool@v1.5.0
# or, to track the newest release
go install github.com/org/tool@latestInstall module-tracked tools from a tools.go
When the tool versions live in your module, install them at the versions go.mod pins.
# inside the module, with the tool listed in tools.go
go install github.com/org/tool # resolves the pinned versionHow to prevent it
- Always install tools with an explicit
@versionin CI. - Prefer pinned versions over
@latestfor reproducible builds. - Track generator/tool versions in a
tools.go.