Repository navigation
Conversation
Set GOMODCACHE and GOCACHE under the runtime user home when switching to MEGALINTER_UID/MEGALINTER_GID, unless already defined. Add a runtime test with a Go fixture that has an external dependency. Fixes #9280
✅
|
|
Likely cause: Generated by Claude Code |
…magupta-8zlr95 # Conflicts: # CHANGELOG.md

Fixes #9280
Problem
When MegaLinter runs with
MEGALINTER_UID/MEGALINTER_GID, the runtime user only gets a writable$HOME. Go keepsGOPATH=/go, so its default module cache/go/pkg/mod(root-owned) can't be written. golangci-lint then fails with the misleadingcontext loading failed: no go files to analyzeerror as soon as a module dependency must be downloaded.Changes
sh/setup-runtime-user.sh: when switching to the runtime user, exportGOMODCACHE=$HOME/go/pkg/modandGOCACHE=$HOME/.cache/go-build, unless the user already set them (the workaround from the issue keeps working). Root runs are unchanged; SSH mode inherits the variables through the savedexport -p.mega-linter-runner/test/runtime-image.test.js: newGO_GOLANGCI_LINTruntime case, run in both root and non-root modes..automation/test/golang_runtime_deps/: fixture module with one external dependency (github.com/google/go-cmp), so the module cache is actually exercised (the existing Go fixture has no dependencies, which is why this was not caught).go env GOMODCACHEinstead of$GOPATH/pkg/mod..cspell.json:GOMODCACHEandGOCACHEadded.CHANGELOG.md: Fixes + Dev entries.Testing
bash -non the script; fixturego.sumgenerated withgo mod tidy; cspell clean on changed files.deploy-DEV.yml) covers the new non-root Go case.