Skip to content

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

Not planned
Not planned
@dolmen

Description

@dolmen

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'

Activity

dolmen

dolmen commented on Jun 21, 2024

@dolmen
ContributorAuthor

Duplicate of #34522, #28337, #50714.

See @rsc comment: #23439 (comment)

dolmen

dolmen commented on Jun 21, 2024

@dolmen
ContributorAuthor

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

reopened this on Jun 21, 2024
dolmen

dolmen commented on Jun 21, 2024

@dolmen
ContributorAuthor

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

seankhliao commented on Jun 21, 2024

@seankhliao
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dolmen@seankhliao@gabyhelp

        Issue actions

          cmd/go: 'go env' should set GOBIN · Issue #68102 · golang/go