-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: "go install" of std/cmd in a different GOROOT silently does the wrong thing #45888
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
Comments
Also, there isn't a gofmt in my GOBIN either. |
I've also seen a very similar pattern with new contributors to Go, where they would do the equivalent of:
That should fail with a very clear message, like "you're using the Go toolchain at /usr/lib/go with the GOROOT at /home/user/tip". |
I'm confused by this. Why re-running make.bash does anything with what "go" binary it is on your PATH? |
That is, That's not the issue at hand, though. The problem is that using the |
You delete the go binary in GOROOT/bin/go before rerunning make.bash? (I agree this is a valid thing to do. I just never done it, so the "go" binary still there, although may be stale.) |
Yes. I essentially do a full |
I put the current funky semantics in place for #30756 — @josharian explicitly wanted to be able to run commands while in a different That said, this behavior affects a very small number of developers, most of whom are Go contributors, so if we think something else would be clearer (and not break anybody's workflow too badly), I'm happy to adjust it. |
Ah, but the funky semantics only really work for module I think that makes this particular example a duplicate of #35270? |
I don't think this is the same as #30756. Running Go from GOROOT_A in GOROOT_B, I think it's fine for Similarly, in my example above I was doing a
I don't mind if this issue is closed as a duplicate, as long as we agree on the issue and that it needs a fix :) I couldn't find a previous issue about it. |
Based on the semantics in #30756,
Ah, but |
(To be clear, I would also be ok with changing the semantics to diverge from #30756, if we can come to a consensus about what the actual behavior ought to be.) |
I honestly don't mind what the final semantics are, as long as running I'd slightly lean towards making both std and cmd cases error, because I struggle to imagine why building a |
Note that Go 1.16.3 happily does nothing when it's told to
go install
cmd/gofmt from tip, even though that should most definitely error. From the last command, you can see that the gofmt I'm using has not changed. The gofmt from /usr/bin can't have been changed either, as I'm not root.I think I get why this is happening.
/usr/bin/go install
turns into/usr/bin/go install cmd/gofmt
, so that ends up installing 1.16.3's cmd/gofmt, which is already up to date - hence nothing to do.But that feels wrong. If I'm installing the package at the current directory, and this is a package under a different GOROOT than the toolchain's, that should simply fail very early on.
This caused me confusion on https://go-review.googlesource.com/c/go/+/284139. After a rebase on a cmd/gofmt change, I ran
go install
and it finished incredibly quickly, even though I knew I had likely made a mistake. Plus, I would expect the first build to take about a second, as I'd need a new binary for sure. It was five minutes later that I realised I had forgot to re-runmake.bash
earlier in the day, so mygo
binary was falling back to the system's 1.16.3, rather than tip.cc @bcmills @matloob
The text was updated successfully, but these errors were encountered: