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

Ambiguous import #1937

Closed
joshklop opened this issue Jan 16, 2023 · 5 comments
Closed

Ambiguous import #1937

joshklop opened this issue Jan 16, 2023 · 5 comments

Comments

@joshklop
Copy link

Hi! I'm importing github.com/ethereum/go-ethereum/core/types, which depends on btcd. When I run go mod tidy, I get the following error:

github.com/filecoin-project/bacalhau/pkg/storage/ethblock imports
	github.com/ethereum/go-ethereum/core/types imports
	github.com/ethereum/go-ethereum/crypto imports
	github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
	github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
	github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
	github.com/btcsuite/btcd v0.22.0-beta (/home/user/.go/pkg/mod/github.com/btcsuite/btcd@v0.22.0-beta/chaincfg/chainhash)
	github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 (/home/user/.go/pkg/mod/github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.1)

Even after reading through a number of issues (#1839, here, here), I have been unable to resolve the issue.

I am on the latest version of go-ethereum. If I create a nearly empty go module and import the github.com/ethereum/go-ethereum/core/types package, I do not get this issue. Any suggestions/pointers would be much appreciated.

@chappjc
Copy link
Contributor

chappjc commented Jan 16, 2023

Can you link to the branch you are working on and/or the go.mod?

@joshklop
Copy link
Author

Thanks for the prompt response! Branch, go.mod

@chappjc
Copy link
Contributor

chappjc commented Jan 17, 2023

Nothing stands out, hmm. Give go get -d github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.2 a shot maybe.

@joshklop
Copy link
Author

That worked! It appears I have some gaps in my understanding of go modules. Where is the -d flag documented?

@chappjc
Copy link
Contributor

chappjc commented Jan 18, 2023

That worked! It appears I have some gaps in my understanding of go modules. Where is the -d flag documented?

It's not you. Go modules are a confusing nightmare. I think there's a go tool bug you were hitting in this case. The btcec/v2 module clearly requires a specific chainhash module, and your project has no direct or transitive requires on btcd (that I can see), so it shouldn't have barfed like this.

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

2 participants