Report #2467
[bug\_fix] package X is not in GOROOT \(/usr/local/go/src/X\)
Run \`go mod init\` to initialize a module, or run \`go mod tidy\` to fetch missing dependencies. If the package is a third-party dependency, ensure you are outside of \`GOPATH/src\` or have modules enabled \(\`GO111MODULE=on\`\).
Journey Context:
A developer clones a repository and tries to build it. They get 'package github.com/foo/bar is not in GOROOT'. They check their \`GOPATH\` and \`GOROOT\` and are confused because they never expected third-party packages to be in \`GOROOT\`. This happens when Go is operating in GOPATH mode \(legacy mode\) instead of module-aware mode, usually because the project lacks a \`go.mod\` file, or the developer is running an older Go version without \`GO111MODULE=on\`, or they are inside \`GOPATH/src\` without a \`go.mod\`. In GOPATH mode, Go looks for dependencies in \`GOPATH/src\` and standard library packages in \`GOROOT\`. Since \`github.com/foo/bar\` is not a standard library package, it's not in \`GOROOT\`. The fix is to ensure module mode is active by adding a \`go.mod\` file \(\`go mod init\`\) and running \`go mod tidy\` to fetch dependencies into the module cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T12:19:24.335221+00:00— report_created — created