Skip to content
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

cmd/go: 'go env' should set GOBIN #68102

Closed
dolmen opened this issue Jun 21, 2024 · 5 comments
Closed

cmd/go: 'go env' should set GOBIN #68102

dolmen opened this issue Jun 21, 2024 · 5 comments

Comments

@dolmen
Copy link
Contributor

dolmen commented Jun 21, 2024

go env GOBIN would be helpful to tools beyond the Go toolchain to determine where go install will install a binary.

However, up to go 1.22.4, the go install directory is not explicitely exposed like GOPATH is. Instead GOBIN is exposed with an empty value.

Go version

go version go1.22.4 darwin/arm64

Output of go env in your module/workspace:

GOBIN=''
GOPATH='/Users/gopher/go'

What did you do?

$ go help environment | sed -n '/GOBIN/{N;p;}'
	GOBIN
		The directory where 'go install' will install a command.
$ env | grep GOBIN
$ cat "$(go env GOENV)"
$ go env GOBIN

$ go env | grep GOBIN
GOBIN=''

What did you see happen?

See above

What did you expect to see?

$ go env GOPATH
/Users/gopher/go
$ env | grep GOBIN
$ cat "$(go env GOENV)"
$ go env GOBIN
/Users/gopher/go/bin
$ go env | grep GOBIN
GOBIN='/Users/gopher/go/bin'
@dolmen
Copy link
Contributor Author

dolmen commented Jun 21, 2024

Duplicate of #34522, #28337, #50714.

See @rsc comment: #23439 (comment)

@dolmen
Copy link
Contributor Author

dolmen commented Jun 21, 2024

Apparently the blocking issue is #23439, so I'm closing.

@dolmen
Copy link
Contributor Author

dolmen commented Jun 21, 2024

Reopening because #23439 seems to be settled if we look at the documentation.

$ go help install | head -9
usage: go install [build flags] [packages]

Install compiles and installs the packages named by the import paths.

Executables are installed in the directory named by the GOBIN environment
variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH
environment variable is not set. Executables in $GOROOT
are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN.

@seankhliao
Copy link
Member

I don't think we need a separate issue, this can be done as #23439

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants