-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: go list -export -e outputs errors to stderr and has non-zero exit code #25842
Comments
It seems to me that That does suggest that we should refine the documentation, though. It's not quite accurate to say that “[w]ith the -e flag, the list command never prints errors to standard error”. |
To make it concrete, the issue I see with this is that as the caller of
We could use some sort of semantic that says "if there is any output on stdout then use it as an indicator of success, compile errors will be reported to stderr", but this seems somewhat brittle. @bcmills do you see another way of me distinguishing between cases 1 and 2 above? Which is why I felt the semantics of
vs:
With |
Hmm, that's a good point. |
May not fix for the release but I'd at least like to understand it better and talk to the go/packages team. |
In general go/packages must expect that the subcommand it runs ("go list" or any other helper like bazel) can exit unsuccessfully and print errors to standard output/error. That should make Load fail, returning an err including the output. The usual way to generate such an error is:
If errors happen during the build for -export, I agree that go list -e should ideally report them in the Package structs. But go/packages must be able to handle the current failure mode regardless, even if it's not quite right for the question that was asked. Leaving for Go 1.12. |
Change https://go.dev/cl/437298 mentions this issue: |
Change https://go.dev/cl/441879 mentions this issue: |
golang.org/cl/437298 updates go list to not exit with a non-zero error code in some cases and instead place the error on the Package struct. Also, as a cleanup, some places where exit status 2 was returned will return exit status 1 (bringing it in line with other errors returned by the go command). TestEncodeDecode in facts_test.go has been updated to fix a missing function body that is not relevant to the test, but that was causing an error because the Package struct now has an error on it. TestRunDespiteErrors in checker_test.go has been updated to reflect that in some cases an analysis with RunDespiteErrors will fail to run because a build error returned by go list when it's run to get export data is not recognized as being a parse/typechecker error (the kind of error allowed by TestRunDespiteError). TestIntegration in unitchecker_test.go has been updated to reflect that go vet running unitchecker will now fail with exit status 1 instead of 2 (so it just checks for a zero or non-zero status). For golang/go#25842 Change-Id: Idbbd19b5de661e6e5f49e0475c5bc918d8e33803 Reviewed-on: https://go-review.googlesource.com/c/tools/+/441879 Reviewed-by: Alan Donovan <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Michael Matloob <[email protected]> gopls-CI: kokoro <[email protected]>
go list -e -export puts errors running build actions on the load.Package corresponding to the failed action rather than exiting with a non zero exit code. For golang#25842 Change-Id: I1fea85cc5a0557f514fe9d4ed3b6a858376fdcde Reviewed-on: https://go-review.googlesource.com/c/go/+/437298 Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
Change https://go.dev/cl/451218 mentions this issue: |
… the import path This refines the error output that was previously adjusted in CL 437298. Longer term, we should consider unraveling the call chains involving formatOutput to avoid passing so many parameters through so many different formatting functions. Updates #25842. Change-Id: I3b9d03bf5968902d8ccc4841ab4dbe114a2239e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/451218 Reviewed-by: Bryan Mills <[email protected]> Auto-Submit: Russ Cox <[email protected]> Reviewed-by: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
@gopherbot, please backport to Go 1.19. This is needed to fix #60650. |
Backport issue(s) opened: #60710 (for 1.19). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/502195 mentions this issue: |
Change https://go.dev/cl/502196 mentions this issue: |
…o list -e -export go list -e -export puts errors running build actions on the load.Package corresponding to the failed action rather than exiting with a non zero exit code. Fixes #60710. Fixes #60650. Updates #25842. Change-Id: I1fea85cc5a0557f514fe9d4ed3b6a858376fdcde Reviewed-on: https://go-review.googlesource.com/c/go/+/437298 Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/502195 TryBot-Bypass: Bryan Mills <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
…n an error that includes the import path This refines the error output that was previously adjusted in CL 437298. Longer term, we should consider unraveling the call chains involving formatOutput to avoid passing so many parameters through so many different formatting functions. Updates #60710. Updates #60650. Updates #25842. Change-Id: I3b9d03bf5968902d8ccc4841ab4dbe114a2239e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/451218 Reviewed-by: Bryan Mills <[email protected]> Auto-Submit: Russ Cox <[email protected]> Reviewed-by: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/502196 Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Bypass: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
I think this was fixed by https://golang.org/cl/437298 and its follow up CLs mentioned in this issue. Please reopen if you're still seeing errors. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No; this is only available in tip.
What operating system and processor architecture are you using (
go env
)?What did you do?
go list
behaves as expected (there are no syntax errors but there is a compile error):But if we add the
-export
and-e
flags we see:I wonder whether my expectations about
-e
are correct in the context of-export
?What did you expect to see?
What did you see instead?
Per the repro steps:
/cc @rsc
The text was updated successfully, but these errors were encountered: