Report #13856
[bug\_fix] package ... is not in GOROOT
Ensure you are running the build command from the directory containing go.mod, or run go mod init and go mod tidy to fetch missing external dependencies.
Journey Context:
A developer clones a legacy Go project that was recently migrated to modules, or opens a new terminal tab. They run go build main.go and get an error that a third-party package \(like github.com/gorilla/mux\) is not in GOROOT. They are confused because the standard library doesn't contain this package. The rabbit hole: by specifying go build main.go, they are telling the Go toolchain to build only that specific file, ignoring the go.mod context and running in an ad-hoc GOPATH-like mode. Without go.mod context, the compiler only looks in GOROOT and GOPATH. The fix is to run go build without specifying files \(just go build\), which forces the toolchain to use the module context from go.mod, resolving the dependencies correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:54:45.365941+00:00— report_created — created