-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: error isn't properly reported when running go list on cgo package with missing pkg-config #35882
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
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Thanks for reporting. This should probably be handled more gracefully in go/packages. Assigning to @matloob. |
I can reproduce the underlying go list issue with the following layout: foo/go.mod:
foo/foo.go:
output of
go list exits with an exit status of 2. I'm going to send a cl to suppress the error in go/packages. There are still two problems in go list. The first is that |
Change https://golang.org/cl/210202 mentions this issue: |
I'm going to repurpose this bug to fix the issue in go list. Note that even when the issue is fixed in go list, if go/packages or gopls are operating on a project that has a dependency on a cgo package that cgo can't successfully be run on, they won't have access to the full set of sources (which need to be generated by cgo). So they might still have problems for those projects. Of course if none of the packages you're working on have a dependency on the offending package, things should work. |
Also note that even after installing pkg-config, go/packages still failed in a similar way because the C library wasn't installed. |
What was the error it failed with? we're probably going to have to put another special case in go/packages to ignore that error... |
|
I'm abandoning the change. We've decided that the cost of the change is greater than the benefit. Because it's impossible to determine which package the error belongs to, we'd have to drop the error (or add errors to all packages) to work around it. In general it's hard for go/packages to work correctly for code that doesn't build. |
When "go list" produces the cgo error and exits uncleanly it still also dumps what seems to be the normal JSON results (minus the cgo generated files). What would happen if we ignored the error and continued using the results? If that is not tenable, is there some way we can at least make gopls able to start in the case of unbuildable cgo package? |
Did CL 209420 help with this at all, or does |
I uninstalled ffmpeg and still got the above panic (on master). Should be easy to reproduce by adding something like this to a file and then restarting gopls: // #cgo pkg-config: some-library
import "C" |
Ah, I just fixed that panic in CL 210215. |
Hot dog! Yes, seems to start up fine now. |
Perfect! So it sounds like we will wait for this fix to be implemented in |
I think this is one instance of a broader problem: execution errors (from running the compiler, linker, or other tools) are not connected back to Fixing that would be too complicated for 1.14 at this point in the freeze. We should consider it for 1.15 though. |
Moving to backlog. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I opened a non-cgo package in our project. The package does not transitively depend on any cgo packages.
What did you expect to see?
I expected gopls to load the package with no issue.
What did you see instead?
gopls failed to create the view due to a
go list
"missing pkg-config" error.Elsewhere, our project has a cgo package that uses the cgo pkg-config directive (e.g.
// #cgo pkg-config: some-library
). My laptop doesn't currently have pkg-config installed.I assume the error comes from the
go list ./...
we do now when creating a view.The text was updated successfully, but these errors were encountered: