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

x/vgo: confusing error when run in go1.9.5 #24694

Closed
jeffallen opened this issue Apr 5, 2018 · 3 comments
Closed

x/vgo: confusing error when run in go1.9.5 #24694

jeffallen opened this issue Apr 5, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jeffallen
Copy link
Contributor

What version of Go are you using (go version)?

go1.9.5, installed via the binary downloader, so that the GOROOT compiled into the runtime is /usr/local/go.

What did you do?

Not read the instructions, try to use vgo with Go 1.9.x:

$ go version
1.9.5
$ go get golang.org/x/vgo
$ vgo list

So vgo ends up installed in $GOPATH/bin/vgo, instead of in $GOROOT/bin/vgo, which would make the code in cfg.go that looks at exe/../.. to see if it is a GOROOT correctly trigger.

What did you expect to see?

A useful error, like the one implemented in vgo's main.go: log.Fatalf("vgo requires Go 1.10")

What did you see instead?

vgo objabi: open /usr/local/go/src/cmd/internal/objabi/zbootstrap.go: no such file or directory
vgo objabi: cannot find GOARM

A related problem was first reported and a fix was made in #23957.

It is happening because vendor/cmd/go/internal/cfg/cfg.go is running objabi() in the init context, so it happens before main.go's Go 1.10 check can happen. And objabi expects cfg.GOROOT to be set correctly, but in findGOROOT, the special case to convert runtime.GOROOT into the real location where the binary distribution was unpacked is not triggered because vgo is installed in $GOPATH/bin.

@gopherbot gopherbot added this to the vgo milestone Apr 5, 2018
@jeffallen
Copy link
Contributor Author

A workaround is to set VGOROOT=$(go env GOROOT), so that zbootstrap.go is at least found, but then this overly aggressive error in objabi() still kills us:

			fmt.Fprintf(os.Stderr, "vgo objabi: cannot find %s\n", key)
			os.Exit(2)

@gopherbot
Copy link

Change https://golang.org/cl/104975 mentions this issue: vgo: fix Go 1.9 check

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 5, 2018
@gopherbot
Copy link

Change https://golang.org/cl/116615 mentions this issue: cmd/go: fix broken TestExecutableGOROOT

gopherbot pushed a commit to golang/vgo that referenced this issue Jun 12, 2018
This test appears to have been broken by https://golang.org/cl/104975.

Updates golang/go#24694.
Updates golang/go#25501.

Before:

~/src/golang.org/x/vgo/vendor/cmd/go$ go test -run=TestExecutableGOROOT .
--- FAIL: TestExecutableGOROOT (0.15s)
    --- FAIL: TestExecutableGOROOT/RuntimeGoroot (0.00s)
        go_test.go:4598: /tmp/gotest104327550/new/bin/go run testdata/print_goroot.go: exit status 1, vgo requires Go 1.10 but VGOROOT=/tmp/gotest104327550/new is not a Go 1.10 source tree
FAIL
FAIL    golang.org/x/vgo/vendor/cmd/go  1.730s

After:

~/src/golang.org/x/vgo/vendor/cmd/go$ go test -run=TestExecutableGOROOT .
ok      golang.org/x/vgo/vendor/cmd/go  2.870s

Change-Id: I155a1344ec704c53d3678390cafc1ad33d1a338b
Reviewed-on: https://go-review.googlesource.com/116615
Reviewed-by: Russ Cox <rsc@golang.org>
@golang golang locked and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants