Navigation Menu

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: ambiguous error message on ambiguous import #32128

Open
jerome-laforge opened this issue May 18, 2019 · 6 comments
Open

cmd/go: ambiguous error message on ambiguous import #32128

jerome-laforge opened this issue May 18, 2019 · 6 comments
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jerome-laforge
Copy link

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

1.12

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build116507160=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I deal with a problem of ambiguous module import when I try to import github.com/spf13/viper@1.3.2 and github.com/gin-gonic/gin@v1.4.0

https://play.golang.org/p/NwzVwWsOjbO

What did you expect to see?

@thepudds (thx to him for his support) has advised me to open a issue to have clearer diagnostic message or a simpler solution.

the proposed solution, that works for me, is:
go get github.com/ugorji/go/codec@none

https://groups.google.com/forum/#!topic/golang-nuts/0mJh8SkaomA

@ALTree ALTree changed the title [modules] Ambiguous message for ambiguous import cmd/go: ambiguous error message on ambiguous import May 18, 2019
@ALTree ALTree added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 18, 2019
@ALTree ALTree added this to the Go1.14 milestone May 18, 2019
@jayconrod
Copy link
Contributor

For reference, the error message is:

build testmod: cannot load github.com/ugorji/go/codec: ambiguous import: found github.com/ugorji/go/codec in multiple modules:
	github.com/ugorji/go v1.1.4 (/tmp/gopath660937702/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
	github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 (/tmp/gopath660937702/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)

The two modules don't require each other at versions that would avoid the ambiguous import.

It's hard to capture all this in an error message, but we might recommend requiring specific versions of these modules to avoid the ambiguous import.

Related #27899

@bcmills
Copy link
Contributor

bcmills commented Aug 8, 2019

It's hard to capture all this in an error message, but we might recommend requiring specific versions of these modules to avoid the ambiguous import.

I think if we can recommend an upgrade that resolves the ambiguous import, we should just apply it instead of telling the user to apply it.

@bcmills
Copy link
Contributor

bcmills commented Aug 8, 2019

the proposed solution, that works for me, is:
go get github.com/ugorji/go/codec@none

I note that this issue predates the resolution of ugorji/go#299.

With that resolved, go get github.com/ugorji/go/codec@latest should also resolve the problem with the module graph. (The versions in the example are still incompatible, but due to breaking API changes rather than an ambiguous import path: https://play.golang.org/p/YXT3Pc69yYM.)

@thepudds
Copy link
Contributor

thepudds commented Aug 8, 2019

For the errors in that playground link, I believe at least one set of the errors is due to fsnotify not supporting nacl/amd64p32.

That might explain all the errors there.

@gopherbot
Copy link

Change https://golang.org/cl/196298 mentions this issue: cmd/go/internal/modload: use a structured error for 'ambiguous import'

gopherbot pushed a commit that referenced this issue Sep 19, 2019
This consolidates the construction of 'ambiguous import' errors to a
single location, ensuring consistency, and lays the groundwork for
automatic resolution in the future.

While we're at it, change "found" to "found package" to try to make
the cause of the error clearer.

Updates #32128
Updates #27899

Change-Id: I14a93593320e5c60d20b0eb686d0d5355763c30c
Reviewed-on: https://go-review.googlesource.com/c/go/+/196298
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@harshakp06
Copy link

Any way to resolve -- ambiguous import: found package time in multiple modules:
??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants