Skip to content

cmd/go: go test and go generate add the wrong go to $PATH when the go command is run from the cross-compiled bin subdirectory #64963

@bcmills

Description

@bcmills

Go version

dfb2e42

What operating system and processor architecture are you using (go env)?

N/A

What did you do?

In a discussion with @matloob about #62114, I remembered the $PATH environment logic that I added to go test and go generate for #51473 (comment).

What did you expect to see?

If the go command is being run from $GOROOT/bin/$GOOS_$GOARCH, as may be the case in multi-arch Go installations, the $PATH setting used for go generate and go test should include that path.

Compare:

What did you see instead?

The $PATH setting includes only $GOROOT/bin:
https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/base/env.go;l=41-45;drc=dfb2e4265bf7654001c77925dfbbb9c38c0d1a95

And the path used for looking up the current go command also checks only $GOROOT/bin:
https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/generate/generate.go;l=490;drc=dfb2e4265bf7654001c77925dfbbb9c38c0d1a95

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions