You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/go: cryptic "neither GOMODCACHE nor GOPATH set" error baffles novice and longtime gophers alike #81825
For the second time in two months I've hit this bug while helping someone get started on their first day of using Go. The user runs git clone go.googlesource.com/go from their home directory, resulting in the creation of $HOME/go. Unfortunately, this name is special, as it causes the go command to assume it's a legacy GOPATH directory, resulting in the cryptic error "neither GOMODCACHE nor GOPATH set" when attempting a build. The solution is not to clone into ~/go but to choose a name such as ~/goroot or ~/work/go. However this is profoundly non-obvious not only to the novice gopher but also to longtime Go users such as myself.
We really need to emit a better error message here, or, ideally, make the tools just work with the default directory name.
Activity
gabyhelp commentedon Sep 28, 2026
Related Issues
Related Discussions
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)