Repository navigation
cmd/go: GOFLAGS=-modcacherw not honored when downloading toolchain for go.mod-triggered switch #81802
Copy link
Copy link
Open
Labels
FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
Go version
go1.26.7 linux/amd64
Output of go env in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-I/nix/store/hpkf5vc3qg0k5gzhdv6mmfyfs8b6yj55-krb5-1.22.1-dev/include'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/nikara/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/nikara/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS='-modcacherw'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2285042261=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/nikara/Projects/viya-risk-data/go.mod'
GOMODCACHE='/home/nikara/Projects/viya-risk-data/.go/pkg/mod'
GONOPROXY=''
GONOSUMDB='*.sas.com,sassoftware.io'
GOOS='linux'
GOPATH='/home/nikara/Projects/viya-risk-data/.go'
GOPRIVATE=''
GOPROXY='goproxy.unx.sas.com'
GOROOT='/home/nikara/Projects/viya-risk-data/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.7.linux-amd64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/nikara/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/nikara/Projects/viya-risk-data/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.7.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.7'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
$ cat go.mod
module example.com/m
go 1.27.1
$ export GOPATH=$(mktemp -d) GOFLAGS=-modcacherw GOTOOLCHAIN=auto
$ go version
go: downloading go1.27.1 (linux/amd64)
go version go1.27.1 linux/amd64
$ ls -ld $GOPATH/pkg/mod/golang.org/toolchain@*
dr-xr-xr-x ... golang.org/toolchain@v0.0.1-go1.27.1.linux-amd64
What did you see happen?
All 1380 directories of the downloaded toolchain are read-only, so rm -rf fails. You need chmod -R u+w or go clean -modcache. Modules downloaded after the switch, with the same GOFLAGS, are writable.
What did you expect to see?
The toolchain directories should be writable, as with any other module downloaded under -modcacherw.
toolchain.Select runs before $GOFLAGS is applied in main.invoke, so cfg.ModCacheRW is still false when Exec downloads the toolchain. #64282 fixed this only for go install pkg@version and go run pkg@version.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Type
Projects
- StatusShow more project fieldsTodo
Activity
cmd/go: honor GOFLAGS=-modcacherw when downloading a toolchain
gabyhelp commentedon Sep 28, 2026
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
gopherbot commentedon Sep 28, 2026
Change https://go.dev/cl/840205 mentions this issue:
cmd/go: honor GOFLAGS=-modcacherw when downloading a toolchainprattmic commentedon Sep 29, 2026
cc @golang/command-line