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

cmd/go: mod vendor introspection #40022

Closed
leventov opened this issue Jul 3, 2020 · 8 comments
Closed

cmd/go: mod vendor introspection #40022

leventov opened this issue Jul 3, 2020 · 8 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@leventov
Copy link

leventov commented Jul 3, 2020

It would be nice if go mod vendor -v not only printed vendored packages, but also packages omitted, and the reasons why they are omitted (see #29074).

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

Go 1.14

@cagedmantis cagedmantis changed the title go mod vendor introspection cmd/go: mod vendor introspection Jul 6, 2020
@cagedmantis cagedmantis added this to the Backlog milestone Jul 6, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 6, 2020
@cagedmantis
Copy link
Contributor

@bcmills @jayconrod @matloob

@jayconrod
Copy link
Contributor

@leventov Could you be more specific? What's an example of a package you expected to be vendored? What message should have been printed?

go mod vendor includes packages imported directly or indirectly by packages in the main module and their tests on any platform. If a package wasn't vendored, it's because it's not imported. It's difficult to come up with a list of packages that weren't imported, so we probably can't do this, but I want to make sure we understand your situation.

@jayconrod jayconrod added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 6, 2020
@leventov
Copy link
Author

leventov commented Jul 6, 2020

Some packages are not vendored (despite being imported) because "build constraints exclude all Go files". So it would be helpful to print exactly that, ideally with the list of constraints imposed by the Go files in the package that are not satisfied.

@jayconrod
Copy link
Contributor

go mod vendor ignores most build constraints though. It should included packages needed to build packages in the main module on any platform.

If you find that's not the case, it may be a bug, so please give a reproducible example.

@leventov
Copy link
Author

leventov commented Jul 6, 2020

In my case the reason (apparently) why a package was not included was because go.mod of the "receiver" module (i. e. the module into where I was vendoring) was specifying go 1.12. When I updated that line to go 1.14, I was able to successfully vendor the package that I wanted. The problem was that nothing whatsoever was pointing me to that fix, I actually noticed that I had an outdated go 1.12 statement by chance.

@jayconrod
Copy link
Contributor

@leventov The go version affects whether the vendor directory may be used automatically (that is, whether -mod=vendor needs to be passed to build commands), but it shouldn't affect the set of packages that go mod vendor copies into the vendor directory. Could you give an example where this is happening?

@leventov
Copy link
Author

leventov commented Jul 6, 2020

I'm not interested in that specific problem, because it is already solved for me. I opened this issue as a meta issue: there should be a way to debug problems like that, whether due to bugs in golang tooling or legitimate behaviour. I was relatively lucky to notice a faulty directive quickly, but I didn't have any means at all to inspect the problem.

@jayconrod
Copy link
Contributor

I'm closing this, since I don't think there's anything we can reasonably do here.

Printing packages that aren't vendored means building a list of packages that weren't imported. Building that list would mean fetching modules we wouldn't normally fetch, possibly encountering new errors. The message we would print next to each package would be something like "not imported directly or indirectly by packages in the main module", which doesn't seem useful.

As I've said, the set of packages that are vendored should not depend on the go version or build constraints. If you find that's not the case, please open a new issue with a reproducible example.

@golang golang locked and limited conversation to collaborators Jul 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants