Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

case-insensitive import collision - Sirupsen vs sirupsen #1010

Closed
bradleyfalzon opened this issue Aug 14, 2017 · 2 comments
Closed

case-insensitive import collision - Sirupsen vs sirupsen #1010

bradleyfalzon opened this issue Aug 14, 2017 · 2 comments

Comments

@bradleyfalzon
Copy link
Contributor

What version of Go (go version) and dep (git describe --tags) are you using?

go version go1.8.3 linux/amd64
v0.3.0-89-gc0338b8

What dep command did you run?

docker run -it --rm  golang:1.8 bash
root@348d3fadc17b:/go#
root@348d3fadc17b:/go#
root@348d3fadc17b:/go# mkdir -p src/test/repo
root@348d3fadc17b:/go# cd src/test/repo
root@348d3fadc17b:/go/src/test/repo#
root@348d3fadc17b:/go/src/test/repo#
root@348d3fadc17b:/go/src/test/repo# cat > main.go <<EOF
package main

import _ "github.com/bradleyfalzon/dep-case-collision"
import _ "github.com/sirupsen/logrus"

func main() {}
EOF
root@348d3fadc17b:/go/src/test/repo# go get github.com/golang/dep/cmd/dep
root@348d3fadc17b:/go/src/test/repo# dep init
  Using master as constraint for direct dep github.com/bradleyfalzon/dep-case-collision
  Locking in master (5263ba3) for direct dep github.com/bradleyfalzon/dep-case-collision
  Locking in 1.0.2 (a3f95b5) for transitive dep github.com/Sirupsen/logrus
  Locking in master (c84c1ab) for transitive dep golang.org/x/sys
  Using ^1.0.2 as constraint for direct dep github.com/sirupsen/logrus
  Locking in 1.0.2 (a3f95b5) for direct dep github.com/sirupsen/logrus
root@348d3fadc17b:/go/src/test/repo# ls
Gopkg.lock  Gopkg.toml  main.go  vendor
root@348d3fadc17b:/go/src/test/repo# go run main.go
package main: case-insensitive import collision: "test/repo/vendor/github.com/Sirupsen/logrus" and "test/repo/vendor/github.com/sirupsen/logrus"

What did you expect to see?

I expected the program to run.

What did you see instead?

package main: case-insensitive import collision: "test/repo/vendor/github.com/Sirupsen/logrus" and "test/repo/vendor/github.com/sirupsen/logrus"

Context

  1. At some stage github.com/Sirupsen/logrus renamed to github.com/sirupsen/logrus (they lowercased the first S in Sirupsen).
  2. A whole series of project continue to import github.com/Sirupsen/logrus, in this case github.com/bradleyfalzon/dep-case-collision imports the old github.com/Sirupsen/logrus
  3. Some new projects have switched to the newer name github.com/sirupsen/logrus, in this case it's our main package.

Is there anything dep can do about this?

I would like to note, go get can't handle this either:

root@348d3fadc17b:/go/src/test/repo# go get -v .
github.com/bradleyfalzon/dep-case-collision (download)
github.com/Sirupsen/logrus (download)
Fetching https://golang.org/x/crypto/ssh/terminal?go-get=1
Parsing meta tags from https://golang.org/x/crypto/ssh/terminal?go-get=1 (status code 200)
get "golang.org/x/crypto/ssh/terminal": found meta tag main.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/ssh/terminal?go-get=1
get "golang.org/x/crypto/ssh/terminal": verifying non-authoritative meta tag
Fetching https://golang.org/x/crypto?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
golang.org/x/crypto (download)
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag main.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
github.com/sirupsen/logrus (download)
can't load package: package test/repo: case-insensitive import collision: "github.com/Sirupsen/logrus" and "github.com/sirupsen/logrus"

But fortunately there's a workaround by moving one of the copies to $GOPATH (or removing one from vendor and go getting it):

root@9e25dfa49b7a:/go/src/test/repo# go run main.go
package main: case-insensitive import collision: "test/repo/vendor/github.com/Sirupsen/logrus" and "test/repo/vendor/github.com/sirupsen/logrus"
root@9e25dfa49b7a:/go/src/test/repo# mv vendor/github.com/Sirupsen $GOPATH/src/github.com/
root@9e25dfa49b7a:/go/src/test/repo# go run main.go
root@9e25dfa49b7a:/go/src/test/repo# echo $?
0
root@9e25dfa49b7a:/go/src/test/repo#

I don't know what the solution is here, in part I'm posting it because the workaround is good enough for me and might help others, but I'd like to know what's dep's thoughts on this, and probably the go team too.

@sdboyer
Copy link
Member

sdboyer commented Aug 14, 2017

yeah, this is definitely a problem. and, actually, something i do think we can do something about. though our power to actually achieve a good solution is limited.

several issues on this already - #797 #806 #433 (so gonna close this as dupe). you've also discovered the interesting tidbit, first shared in #433 (comment), that even on case-sensitive filesystems, the compiler will reject these. that sorta makes it easier for us, as it makes it OK for us to create global satisfiability rules the solver can enforce to detect and reject these situations. that's nice, because people won't get build or checkout errors, but still crappy, because it means some projects are just literally incompatible with having their dependencies flattened together simply because of variances in import case.

we can get through this, it's just going to take some elbow grease.

@sdboyer sdboyer closed this as completed Aug 14, 2017
@bradleyfalzon
Copy link
Contributor Author

Thanks @sdboyer and sorry for the dupe! I had searched elsewhere for this issue, but not the place I was posting the issue! Sorry for the noise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants