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

cmd/go: confusion on case-insensitive file systems #4773

Closed
btracey opened this issue Feb 8, 2013 · 5 comments
Closed

cmd/go: confusion on case-insensitive file systems #4773

btracey opened this issue Feb 8, 2013 · 5 comments
Milestone

Comments

@btracey
Copy link
Contributor

btracey commented Feb 8, 2013

What steps will reproduce the problem?

I imported "math/Rand" instead of "math/rand".
http://play.golang.org/p/ryDFKo0Lt6 reproduces the problem (but the problem is not
reproduced in the playground)

What is the expected output?
The compiler error as seen in the playground "prog.go:4: can't find import:
"math/Rand" "

What do you see instead?

The code successfully compiles and runs (without any issue) on the exact code in the
playground. On a more complicated code (which is too long to produce here, and I don't
know what a representative short version is), I get "pack" errors of the form
pack: non-object file $WORK\math\rand\_obj\_go_.6

and/or

pack: zero length file $WORK\math\rand\_obj\_go_.6

Which compiler are you using (5g, 6g, 8g, gccgo)?
gc

Which operating system are you using?
Windows 7 Professional, 64 bit

Which version are you using?  (run 'go version')
1.0.3

Please provide any additional information below.
https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/du5ePG0z1eY for more
information
@rsc
Copy link
Contributor

rsc commented Feb 8, 2013

Comment 1:

The problem here is that your program also imports math/rand, so the Go command tries to
build both math/Rand and math/rand, having checked that both directories contain package
sources. What it doesn't know is that they're the same directory. Worse, when it tries
to build the two - in parallel - it writes one to $WORK\math\rand\obj and the other to
$WORK\math\Rand\obj. Of course, those are the same directory too, so the one compilation
is overwriting the first's files as the first tries to pack them into an archive. That
causes the pack errors.
I suppose one solution is to use SameFile to decide if two directories are the same, but
that will be system dependent.
Another possible solution is to reject any program that imports (perhaps indirectly) two
paths that differ only in case. That's what I'm leaning toward right now.
Thanks for the report.

Labels changed: added priority-later, go1.1, removed priority-triage, go1.1maybe.

Owner changed to @rsc.

Status changed to Thinking.

@btracey
Copy link
Contributor Author

btracey commented Feb 8, 2013

Comment 2:

I unfortunately don't know enough of the specifics, but is there a way to force the
existence check on the exact characters/runes? I'm just thinking there my be similar
issues that don't involve case, for example é and e. 
Do you know if there would be a similar issue with files within a package? Windows
doesn't let me create a foo.go and Foo.go in the same package, but could in happen in
other OSes? Maybe you also need to forbid (already are forbidding) two .go files that
only differ in case.

@alexbrainman
Copy link
Member

Comment 3:

I think SameFile is more dependable. "case dependency" will help here, but we will
discover different scenarios. Better be safe then sorry.
If people have foo.go and Foo.go in the same package and come to build it on windows,
then they are looking for trouble. Nothing Go can do about that.
Alex

@rsc
Copy link
Contributor

rsc commented Feb 15, 2013

Comment 4:

This issue was closed by revision 2d41645.

Status changed to Fixed.

@rsc
Copy link
Contributor

rsc commented Mar 11, 2013

Comment 5:

SameFile is not helpful here, because it varies from system to system. The goal is to do
something that will catch all the SameFile cases (or at least all the ones that will be
encountered in practice), even on case-sensitive systems, so that people do not
inadvertently create packages that cannot be built on Windows.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants