Report #2469
[bug\_fix] go: go.mod file is read-only or open go.mod: permission denied
Check if the project directory is mounted as read-only \(common in Docker containers\), or if the \`go.mod\` file has restrictive file permissions. Change permissions using \`chmod\` or mount the volume with write access.
Journey Context:
A developer is building a Go application inside a Docker container using a multi-stage build. They run \`go mod tidy\` as part of the build process and get a 'permission denied' or 'read-only' error on \`go.mod\`. They check the local repository and it's fine. The issue is that they copied the project files into the container as the root user, but are running the \`go build\` command as a non-root user \(e.g., \`USER nobody\`\). Alternatively, they mounted the source code as a read-only volume to prevent accidental writes during the build. The Go toolchain needs write access to \`go.mod\` and \`go.sum\` because \`go mod tidy\` and \`go build\` \(which implicitly fetches missing dependencies\) update these files to record exact dependency versions and hashes. The fix is to ensure the build process has write permissions to the directory containing \`go.mod\`, either by adjusting the Dockerfile's \`COPY\` ownership \(\`COPY --chown=...\`\) or removing the read-only mount flag.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T12:19:24.497306+00:00— report_created — created