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

Azure go-autorest causing ambiguous import #628

Closed
yashbhutwala opened this issue Jul 3, 2019 · 4 comments
Closed

Azure go-autorest causing ambiguous import #628

yashbhutwala opened this issue Jul 3, 2019 · 4 comments

Comments

@yashbhutwala
Copy link

Got an ambiguous import error when run go get ./... under a go module enabled project with client-go v12.0.0

build github.com/.../cmd/operator: cannot load github.com/Azure/go-autorest/autorest: ambiguous import: found github.com/Azure/go-autorest/autorest in multiple modules:
	github.com/Azure/go-autorest v11.1.2+incompatible (/.../github.com/!azure/go-autorest@v11.1.2+incompatible/autorest)
	github.com/Azure/go-autorest/autorest v0.3.0 (/.../github.com/!azure/go-autorest/autorest@v0.3.0)

Looks like go-autorest, at least v11.1.2, is introduced by client-go

Here is the line in my go.mod file:

github.com/Azure/go-autorest/autorest v0.3.0 // indirect

but in the go.sum, there are many lines:

github.com/Azure/go-autorest v11.1.2+incompatible h1:viZ3tV5l4gE2Sw0xrasFHytCGtzYCrT+um/rrSQ1BfA=
github.com/Azure/go-autorest v11.1.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/Azure/go-autorest/autorest v0.3.0 h1:yOmXNB2qa2Kx40wMZB19YyafzjCHacXPk8u0neqa+M0=
github.com/Azure/go-autorest/autorest v0.3.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg=
github.com/Azure/go-autorest/autorest/adal v0.1.0 h1:RSw/7EAullliqwkZvgIGDYZWQm1PGKXI8c4aY/87yuU=
github.com/Azure/go-autorest/autorest/adal v0.1.0/go.mod h1:MeS4XhScH55IST095THyTxElntu7WqB7pNbZo8Q5G3E=
github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM=
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
github.com/Azure/go-autorest/autorest/mocks v0.1.0 h1:Kx+AUU2Te+A3JIyYn6Dfs+cFgx5XorQKuIXrZGoq/SI=
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
github.com/Azure/go-autorest/tracing v0.1.0 h1:TRBxC5Pj/fIuh4Qob0ZpkggbfT8RC0SubHbpV3p4/Vc=
github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88=
@nikhita
Copy link
Member

nikhita commented Jul 4, 2019

Looks like this is because how multi modules are configured in Azure/go-autorest. This is similar to ugorji/go#279.

Also, similar errors have been reported for Azure/go-autorest in Azure/go-autorest#414 and google/go-cloud#1990.

This occurs because:

v11.1.2 -> doesn't have github.com/Azure/go-autorest/autorest{go.mod,go.sum} files.

autorest/v0.3.0 -> has github.com/Azure/go-autorest/autorest{go.mod,go.sum} files.

To fix this, you'll need to tell go to use a version of github.com/Azure/go-autorest that has github.com/Azure/go-autorest/autorest{go.mod,go.sum} files.

autorest/v0.3.0 and v12.2.0 point to the same commit, so adding the following line to your go.mod file should fix it.

require github.com/Azure/go-autorest v12.2.0+incompatible

@nikhita
Copy link
Member

nikhita commented Jul 4, 2019

fyi @sttts @liggitt @dims

@nikhita
Copy link
Member

nikhita commented Jul 5, 2019

Closing this issue since this is not a bug with client-go. This issue will only be hit if someone's using something in their go.mod that requires github.com/Azure/go-autorest/autorest v0.3.0.

Having said that, this issue should go away once kubernetes/kubernetes#79574 has merged. :)

@BruceWangNo1
Copy link

To anyone who is struggling with this issue, I managed to avoid this problem by removing the following two lines in go.mod.

github.com/Azure/go-autorest/autorest v0.9.2 // indirect
github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
go mod tidy

pst added a commit to kbst/terraform-provider-kustomization that referenced this issue Jan 15, 2020
ytsarev added a commit to k8gb-io/k8gb that referenced this issue Jun 22, 2020
ytsarev added a commit to k8gb-io/k8gb that referenced this issue Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants