ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.18k stars 3.02k forks source link

protocol by the name "dns4" already exists importing core package #6753

Closed mediocregopher closed 5 years ago

mediocregopher commented 5 years ago

Version information:

Using go-ipfs as a library, I encounter this problem in versions v0.4.19 through v0.4.22 (the current version). go version: go1.13.3 linux/amd64

Description:

Simply importing the core package causes a panic during init. Here's a super basic test case that does it:

package foo

import (
    "testing"
    _ "github.com/ipfs/go-ipfs/core"
)

TestAnything(t *testing.T) { }

causes the following on my machine:

panic: error registering dns4 protocol: protocol by the name "dns4" already exists

goroutine 1 [running]:                                                                                                                                                    
github.com/multiformats/go-multiaddr-dns.init.0()                                                                                                                         
        /home/mediocregopher/src/go/pkg/mod/github.com/multiformats/go-multiaddr-dns@v0.0.2/dns.go:42 +0x21a                                                              
FAIL    gossip  0.008s                                                                                                                                                    
FAIL
Stebalien commented 5 years ago

You've updated github.com/multiformats/go-multiaddr. You can either downgrade it to the version used in go-ipfs or upgrade the following packages to the latest version:

We moved protocol definitions from other packages into go-multiaddr itself and, unfortunately, go modules don't have "carrot" dependencies like npm.

mediocregopher commented 5 years ago

Just to clarify a bit for anyone searching in the future: The problem specifically was that I had github.com/libp2p/go-libp2p-core v0.2.4 in my go.mod, which requires a higher version of github.com/multiformats/go-multiaddr v0.1.1 than go-ipfs allows v0.0.4.