Report #104284
[bug\_fix] go: updates to go.mod needed, disabled by -mod=readonly
Run \`go mod tidy\` to update go.mod and go.sum, or temporarily use \`-mod=mod\` to allow modifications during build. For CI, ensure that \`go mod tidy\` is executed before the build step and that the updated files are committed.
Journey Context:
A developer added a new dependency by editing go.mod manually, then ran \`go build\`. The build failed with 'updates to go.mod needed, disabled by -mod=readonly'. The developer was unaware that \`go build\` defaults to \`-mod=readonly\` in Go 1.16\+ when no go.sum is present or when the module is in module mode with a read-only file system. They tried to build again with \`-mod=mod\` and it worked, but the CI pipeline still failed because it used the default readonly mode. The proper fix was to run \`go mod tidy\` to compute the correct go.sum and update go.mod automatically. After committing the updated go.mod and go.sum, the CI passed. The root cause: Go's readonly mode prevents accidental modifications to the module files during builds; any changes needed \(like adding a missing dependency\) must be done explicitly via \`go mod tidy\` or \`go get\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:04:33.376623+00:00— report_created — created