Skip to content

cmd/go: cryptic "neither GOMODCACHE nor GOPATH set" error baffles novice and longtime gophers alike #81825

Open

Description

@adonovan

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.

Prior reports:

Metadata

Metadata

Assignees

Labels

GoCommandcmd/goNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions