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

Open
@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

Activity

added
NeedsFixThe path to resolution is known, but the work has not been done.
on Jan 4, 2024
added this to the Backlog milestone on Jan 4, 2024
self-assigned this
on Jan 4, 2024
gopherbot

gopherbot commented on Feb 2, 2024

@gopherbot
Contributor

Change https://go.dev/cl/560782 mentions this issue: cmd/go: fix tests that fail when running a cross-compiled GOARCH

removed their assignment
on Mar 14, 2024
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

    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

        Participants

        @bcmills@gopherbot

        Issue actions

          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 · Issue #64963 · golang/go