Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: print import stack when reporting error constructing build list #30661
In module mode, every build starts by constructing the build list, the set of modules at specific versions that will be involved in the build. We construct the build list by exploring the import graph rooted at the command line arguments, adding modules to satisfy any imports that can't be resolved.
There are a number of things that can go wrong during this process, not all of which are under the user's direct control. For example, suppose a transitive dependency requires
When an error like this occurs, we should report the chain of imports from the command line arguments to the problematic package.
@jayconrod I had this question when ran this for the first time.
If you see an error like this:
First, does the first transition there represent an upgrade? If so, I didn't understand that at first, and at first I thought that
Second, I think the main module is implied? If so, maybe the "get" could be eliminated and add in the main module as the first line?
I don't think this is quite perfect, but maybe something like:
About the main module, unfortunately, that's a difficult change to make because we don't know whether requirements are direct or transitive when that error comes up.
We should refactor this. It will be a complicated change though.
mvs.BuildList reports errors with a chain of modules to make it clear why the module where the error occurred was part of the build. This is a little confusing with "go get -u" since there are edges in the module graph for requirements and for updates. With this change, we now print "requires" or "updates to" between each module version in the chain. Updates #30661 Change-Id: Ie689500ea86857e715b250b9e0cae0bc6686dc32 Reviewed-on: https://go-review.googlesource.com/c/go/+/171150 Run-TryBot: Jay Conrod <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Bryan C. Mills <firstname.lastname@example.org>