-
Notifications
You must be signed in to change notification settings - Fork 1k
adding a go-import "mod" meta tag makes dep ensure fail with "multiple meta tags match" error #2151
Comments
The problem in code is inside the Lines 58 to 70 in 66ec1e8
The fix should be as little as: continue
}
if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 {
+ // Ignore VCS type "mod", which is applicable only in module mode.
+ if f[1] == "mod" {
+ continue
+ }
imports = append(imports, metaImport{
Prefix: f[0],
VCS: f[1], This issue and the fix for it are very similar to issue golang/go#31845 that was affecting the |
I understand this is small and the fix is trivial, but it's still annoying how tools that used to work OK now suddenly need more investment in order to behave the same way that they did before. I thought the whole point of Go was to preserve compatibility, etc. |
Apply the same change as in golang.org/cl/175219 to this copy of the parseMetaGoImports function, helping keep them in sync. The "mod" type is not a real version control system (VCS), it applies only when in module mode. Skip it and continue to consider only real VCS types. This resolves parseMetaGoImports returning a "multiple meta tags match import path" error on packages that offer go-import meta tags with both a true VCS and the "mod" type. Reference: https://golang.org/cmd/go/#hdr-Remote_import_paths Fixes #2151
I’ve sent PR #2152 that resolves this issue. I tested it on the package in the original issue report, and |
The following repo includes a It will clone the dep repo, apply the patch, build and install the patched This make it easier for us to deploy this fix in our automated builds. It goes without saying but I will say it: Use at your own risk. You may have to modify the |
Apply the same change as in golang.org/cl/175219 to this copy of the parseMetaGoImports function, helping keep them in sync. The "mod" type is not a real version control system (VCS), it applies only when in module mode. Skip it and continue to consider only real VCS types. This resolves parseMetaGoImports returning a "multiple meta tags match import path" error on packages that offer go-import meta tags with both a true VCS and the "mod" type. Reference: https://golang.org/cmd/go/#hdr-Remote_import_paths Fixes #2151
The fix has been merged to It hasn't been included in a released version yet, but it can be installed right now from source code via I've confirmed the original issue is resolved with the latest version:
|
This problem with
dep
failing was reported to me as the author of a Go package, see here.I've looked into the cause and reporting it here because it seems like a bug in
dep
.What version of
dep
are you using (dep version
)?The latest via
go get -u github.com/golang/dep/cmd/dep
as of right now, commit 66ec1e8. Runninggit describe --tags
reportsv0.5.1-3-g66ec1e84
.What
dep
command did you run?What did you expect to see?
Successful operation.
What did you see instead?
Cause
The Go package at the vanity import path dmitri.shuralyov.com/text/kebabcase currently has two go-import meta tags, one with the VCS type "git" telling the go command where to clone the containing repository via git, and another with the type "mod" telling the go command what Go module proxy can be used to fetch the module.
The "mod" go-import meta import is documented at the bottom of https://golang.org/cmd/go/#hdr-Import_path_syntax section.
The "mod" meta tag seems to be causing
dep
to think there are two VCS types and it throws the above error. Ifdep
doesn't have full support the "mod" meta tag, it should be skipping over it instead of reporting an error.The
go
command has no problems with fetching that module, both in Go 1.12 and Go 1.11.The text was updated successfully, but these errors were encountered: