Logrus: case-insensitive import collision

Created on 12 May 2017  Â·  34Comments  Â·  Source: sirupsen/logrus

Hi,

My last build today I have this problem.

can't load package: package github.com/sirupsen/logrus/examples/hook: case-insensitive import collision: "github.com/Sirupsen/logrus" and "github.com/sirupsen/logrus"

can i help me ?

Most helpful comment

I am terribly sorry for how messy this is. But I truly believe the best option at this point is biting the bullet and going full on lower-case at this point.

All 34 comments

Why are you importing the example hook?

It happens if you're trying to build the example:

$ go build ./examples/hook                                                                                             
can't load package: package github.com/sirupsen/logrus/examples/hook: case-insensitive import collision: "github.com/Sirupsen/logrus" and "github.com/sirupsen/logrus"

I have opened a pull request to fix logrus-airbrake-hook, which fixes building for me locally:
https://github.com/gemnasium/logrus-airbrake-hook/pull/2

I am also getting this. We are not using the example in our project. :(

I have the same problem without using an example.

What errors are you getting?

Sorry, I should post it in my comment! This is the error I am getting. It also occurs, if I fetch the needed libraries (go get)
main.go:11:2: case-insensitive import collision: "github.com/Sirupsen/logrus" and "github.com/sirupsen/logrus"

Same here

Do you have a dependency that depends on upper-case, or lower-case, and then you're importing the opposite case?

As far as i can tell they all use upper-case, except for your examples :)

This fixes my problem: https://github.com/stweiz/logrus/commit/0ae413d7e0443fffe6fb8e6533de973c1d85b139

I see, that you wrote in your README, that all import paths should be written in lower-case letters, but I recognized, that in the logrus project the first letter is either upper-case, or lower-case.

This problem should be fixed, if the import paths in our projects are all the same. So the first letter should be lower-case, right?

So this should be the correct one: https://github.com/sirupsen/logrus/compare/master...stweiz:issue_543_lower-case-imports

So everyone who uses the library, needs to set their imports lower-case.

I don't use example... continues here yet

I have created a pull request: https://github.com/sirupsen/logrus/pull/546

With this PR everything would work for us if we change it to lowercase everywhere (which is fine).
The only problem are some "transient" dependencies (specifically https://github.com/Shopify/toxiproxy) which use the upper-case variant. I opened an issue there.

@sirupsen can we expect to see it merged to the master soon?

Are people getting this due to using the test package, and syslog? I created a null logger package that importa lower-case. We cannot just change the casing, as people depend on the upper-case import as well. This is a sticky situation, so we have to tread very carefully. It's possible we should instead take syslog out of core with a lower-case import, and deprecate the package in core.

@sirupsen we get this from syslog, yeah

@ypatent we'll have to copy that directory and provide symlinks, then reference logrus with lowercase. I don't want to reference lowercase in core _just yet_.

I'm getting the same today, trying to use the elasticsearch hook

case-insensitive import collision: "github.com/Sirupsen/logrus" and "github.com/sirupsen/logrus"

the uppercase variant is still present in the syslog hook, causing build errors. I have manually edited the two files (syslog and test) and I can build correctly

(Issue #553 is directly related to this). I am stating the obvious here, and firstly thank you for a great logging package, but when your project is widespread use (Congratulations!), or you hope it will be, global changes like these are a big no, no. The community values stability so we can run our production systems without worry. One reason for Go's widespread adoption is the 1.0 guarantee. In everything we do as open source developers, we should make stability a very high priority. Thanks again. So which way are we going, lower or upper 'Sirupsen'?

Lower-case. This has been a mess since my handle was re-named, and the best long-term strategy is that everyone converts to lowercase. There's no turning back, as regretful as that is.

As mentioned in other issues, I failed to realize the implications this would have given Go's package management.

I am terribly sorry for how messy this is. But I truly believe the best option at this point is biting the bullet and going full on lower-case at this point.

For glide users theres a workaround in https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437 . But remember to PR your dependencies not to rely on this hack for long :)

I think in the future we should have a legal age for creating account in Github or other remote repository.

Still have the problem... Go 1.8

What happened, in my case, is that some files used the uppercase one and some used the lower case one. So I've simply used the same type in all of the files

Dealing with this issue on several prod systems now, very frustrating and amateurish

# /usr/bin/ag 'github.com/sirupsen/logrus'
Godeps/Godeps.json
34:                     "ImportPath": "github.com/Sirupsen/logrus",
236:                    "ImportPath": "github.com/sirupsen/logrus",

docker.go
9:      log "github.com/sirupsen/logrus"

[...]

vendor/github.com/Azure/go-ansiterm/parser.go
8:      "github.com/sirupsen/logrus"

vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go
12:     "github.com/sirupsen/logrus"

[...]

vendor/github.com/docker/docker/pkg/archive/copy.go
12:     "github.com/Sirupsen/logrus"

vendor/github.com/docker/docker/pkg/archive/example_changes.go
16:     "github.com/Sirupsen/logrus"

Well… Fine… When dependencies import their dependencies and fuck up your project…

can't load package: package github.com/Luzifer/dockermanager: case-insensitive import collision: "github.com/Luzifer/dockermanager/vendor/github.com/Sirupsen/logrus" and "github.com/Luzifer/dockermanager/vendor/github.com/sirupsen/logrus"

I completely agree that this was amateurish.

Please see https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276 for an extended comment.

I am also seeing this error:
go build
vendor/github.com/lyft/gostats/logging_sink.go:3:8: case-insensitive import collision: "github.com/sys-test/vendor/github.com/sirupsen/logrus" and "github.com/sys-test/vendor/github.com/Sirupsen/logrus"

I am using glide up --strip-vendor which removes nested vendor directory, which results in the import collision
case-insensitive import collision: "github.com/portworx/torpedo/vendor/github.com/Sirupsen/logrus" and "github.com/portworx/torpedo/vendor/github.com/sirupsen/logrus"

Although the strange fact is, when I do a go build on the code it does not throw this error, it happens only on go test.
The packages that I import have a mix of lower and upper case Sirupsen/logrus imports. On glide up, it creates both vendor/Sirupsen and vendor/sirupsen directories. Is there a work around for this?

@piyush-nimbalkar, I'm actually having the same issue and it is very peculiar indeed.

I'm having the same case-insensitive collision with the latest moby/moby (docker/docker) release since they vendored Sirupsen and we are using sirupsen. Due to vendor flattening we now get the collision.

That rename caused sooo much issues -.-

I am also getting this. We are not using the example in our project. :(

same here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Integralist picture Integralist  Â·  3Comments

demizer picture demizer  Â·  4Comments

UnAfraid picture UnAfraid  Â·  5Comments

kubistika picture kubistika  Â·  3Comments

oconnor663 picture oconnor663  Â·  3Comments