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: confusion about modules not kicking on in GOPATH/src by default #26394
Comments
Is it possible for you to share an example repo that duplicates this? I'm not sure how it pulled one dep from a module and another dep from a vendor folder. |
Not trivially, no, this is in a private repo. Repository A vendors repository B. Both repository A and B have |
I should also mention that vendoring is currently managed with dep. |
In module mode, the
Which vendored copy do you expect the build to use? If both A and B vendor the same pristine copy of On the other hand, if the vendored copy has changes that are intentionally not compatible with a tagged release of |
If the vendored copy of |
It's the same pristine version, so I don't care which one it uses.
Only one of the two repositories has been "go modularised", repository A. |
One question, should I be able to delete the vendor directory at this stage of development, or is that still a work in progress? |
If you don't need reproducible builds without module support, you should be able to delete the vendor directory. (In module mode, you should be able to build without it.) That's a pretty big “if”, but it's your repo. 🙂 |
The report is a bit hard to follow since it is so abstract, but this error looks wrong to me:
When using go modules, vendor directories should be ignored entirely. It should not be possible to end up with a package "importedproject/vendor/github.com/aws/aws-sdk-go/aws/credentals" in the build at all. It sounds like "importedproject/somethig" imports "github.com/aws/aws-sdk-go/aws/credentials" and that resolved to the vendored copy instead of the real one chosen for the overall build. If so, that's a mistake. We just need to isolate the test case showing why it happens. A little more information would help. Can you post your go.mod (with "importedproject" or whatever is fine)? Can you tell if importedproject imports "github.com/aws/aws-sdk-go/aws/credentials"? Does it import it using that exact path? Or maybe does it import it using "importedproject/vendor/github.com/aws/aws-sdk-go/aws/credentals? (That should be impossible but we've already established there's a bug somewhere.) Thanks. |
I've replicated this in some minimal public repositories:
Apologies for not having a replicable example before. As I mentioned initially, I'm not sure this specific combination of actions is expected to work at all, or is even reasonable to expect to work. |
It is expected to work with |
Aha! Setting |
I'm really sorry but the problem here is that modules are not enabled for your commands. I will take this as a sign that we need to make the non-module usage inside GOPATH/src clearer. Maybe even a warning print, as much as I hate those. Perhaps go mod -init should have failed too.
|
Ah, of course. That makes complete sense now. |
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?
Yes.
What operating system and processor architecture are you using (
go env
)?darwin amd64
What did you do?
go mod -init
on a project that imports a dependency that vendors and imports a mutual shared dependency. ie.A -> C, A -> B -> C
What did you expect to see?
The mutual shared dependency should be resolved to the same import, but is not.
I can understand why it doesn't support this, but it makes piecemeal migration difficult. Packages would have to be migrated in the order of their dependencies.
What did you see instead?
The text was updated successfully, but these errors were encountered: