Skip to content

cmd/go: improve 'missing $GOPATH' error message when HOME is unset #29341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bitfield opened this issue Dec 19, 2018 · 3 comments
Closed

cmd/go: improve 'missing $GOPATH' error message when HOME is unset #29341

bitfield opened this issue Dec 19, 2018 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bitfield
Copy link

bitfield commented Dec 19, 2018

With reference to #24064, this is a common occurrence when trying to automate the installation of Go programs with tools such as Puppet. System commands are run in an initially empty environment, so a command like:

GO111MODULE=on go get github.com/bitfield/cronrun/cmd/cronrun@v0.3.2

fails with this error:

missing $GOPATH

But this works fine in a 'normal' interactive environment, because GOPATH is inferred from the value of $HOME. What's missing here is not $GOPATH, per se, but $HOME.

Maybe this error message could be improved, along the lines of:

GOPATH not set; unable to default to '$HOME/go' because HOME is not set either. Please set either GOPATH or HOME.

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go modules labels Dec 19, 2018
@bcmills bcmills added this to the Go1.13 milestone Dec 19, 2018
@ALTree ALTree changed the title Improve 'missing $GOPATH' error message when HOME is unset cmd/go: improve 'missing $GOPATH' error message when HOME is unset Dec 19, 2018
@bcmills bcmills modified the milestones: Go1.13, Go1.12 Dec 19, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/158257 mentions this issue: cmd/go/internal/modload: improve error message when $HOME is unset

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/331529 mentions this issue: go/build: improve error message when GOPATH is unset

@golang golang locked and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants
@rsc @bitfield @andybons @bcmills @gopherbot and others