How to find dependency causing "Sirupsen/logrus" vs. "sirupsen/logrus" unexpected module path error?
Asked Answered
N

1

7

I am trying to convert https://github.com/appscode/voyager from glide to go mod.

I am getting an error like below:

go: github.com/Sirupsen/[email protected]: parsing go.mod: unexpected module path "github.com/sirupsen/logrus"
go: error loading module requirements

How do I find out the source of this old Sirupsen module?

Nerve answered 8/5, 2019 at 1:59 Comment(4)
Have you tried using go mod why? Although if you can't parse go.mod, I'm not sure what you can do other than remove the offending module path. (also make sure you're using the latest go release to generate go.mod, and run go mod tidy)Rivy
Cross-posted: groups.google.com/forum/#!topic/golang-nuts/mJcpYYim3-wExhilarative
"How do I find out the source of this old Sirupsen module?" - it's not old, it's still actively maintained, and the source is exactly where the import path indicates: github.com/sirupsen/logrusCompendious
Yes, 1.4.1 was long after the rename, there should be no reason to have the Sirupsen path in your code.Rivy
O
9

How do I find out the source of this old Sirupsen module?

Use the Go 1.13 beta (go get golang.org/dl/go1.13beta1 && go1.13beta1 download) or even better, try the latest Go on tip / master (go get golang.org/dl/gotip && gotip download).

Go 1.13 has improved error messages in general. It should help in your case, including most likely showing the import chain leading up to the error.

For example:

$ gotip build .
go: example.com/temp/mod imports
        github.com/docker/libcompose/docker imports
        github.com/Sirupsen/logrus: github.com/Sirupsen/[email protected]: parsing go.mod:
        module declares its path as: github.com/Sirupsen/logrus
                but was required as: github.com/sirupsen/logrus

In that example, you can see that docker/libcompose/docker is importing the old and now incorrect uppercase version of Sirupsen/logrus.

The most common reason people see a Sirupsen/logrus vs. sirupsen/logrus case mismatch is when importing github.com/docker/docker or one of the other docker repos. Importing docker repos is a bit confusing with modules, including because:

  • The docker/docker repo does not follow semver.
  • There is a very old v1.13.1 semver tag on the docker/docker repo.
    • Even though it is a couple years old, it is still the "latest" semver tag on that repo, and hence that old version is picked by default by the go command if you don't ask for a more specific version.
    • That old docker/docker version imports the old and not incorrect uppercase Sirupsen/logrus, which can then trigger the error reported in the question above.
  • The docker client package has had breaking changes after v1.13.1.
  • There is generally confusion about docker/docker vs. docker/engine repositories, and about what import paths to use.
  • The docker repos do not have go.mod files.

For the docker/docker repo, the import path remains github.com/docker/docker, but it needs to come from github.com/docker/engine, so the recommended approach is often for a docker importer to do import "github.com/docker/docker" and edit their go.mod to something like this:

require (
    github.com/docker/docker v1.13.1
)

replace github.com/docker/docker => github.com/docker/engine <tag-or-commit-hash>

Docker issue #39302 tracks trying to document how to import docker repos when using modules.

Ornate answered 2/8, 2019 at 16:45 Comment(1)
I tried to do this with docker/distribution but get this: replace github.com/distribution/distribution: version "v2.7.1" invalid: should be v0 or v1, not v2Neisse

© 2022 - 2024 — McMap. All rights reserved.