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: support ~ in import paths #9193

Closed
gopherbot opened this issue Dec 2, 2014 · 14 comments
Closed

cmd/go: support ~ in import paths #9193

gopherbot opened this issue Dec 2, 2014 · 14 comments

Comments

@gopherbot
Copy link

by henderson.bj:

What does 'go version' print?

go version go1.3.3 linux/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. go get -d gitserver/~user/repo.git

What happened?

package gitserver/~user/repo.git: unrecognized import path
"gitserver/~user/repo.git"

What should have happened instead?

The repository should have been checked out.

Please provide any additional information below.

git ls-remote works on the supplied path, so it's a valid url.
I believe the relevant line is here:

https://code.google.com/p/go/source/browse/src/cmd/go/vcs.go?name=go1.3.3#618

This line in tip has not changed.

I tested manually checking out the repo into the same path and everything else (import,
build) seemed to work.

thank you,
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.5.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed the repo-main label Apr 14, 2015
@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

Sadly I am postponing this to Go 1.6. It is too late to find out what the answer is here. I am worried about Windows in particular having unanticipated problems with the ~.

@rsc rsc modified the milestones: Go1.6Early, Go1.5 Jun 29, 2015
@stemar94
Copy link

@adg You should add Proposal Label here (I read you are going to do discussions about proposals).

@minux minux changed the title cmd/go: can import path be expanded to support ~ characters? proposal: support ~ in import paths Sep 30, 2015
@minux minux added the Proposal label Sep 30, 2015
@adg
Copy link
Contributor

adg commented Oct 21, 2015

If someone wants to write a proposal document for this, I'd be happy to provide feedback.

@bradfitz
Copy link
Contributor

Does this really need a full proposal? I'd say fix the regexp, test on Windows, and ship it if it works there?

@rsc
Copy link
Contributor

rsc commented Oct 24, 2015

The possible problems I expect on Windows are subtle (remember that ~ is how Windows shortens long path names to 8.3 format). "Test it once and ship it" is NOT okay.

It may be okay to accept ~ only at the beginning of a path element.

@rsc rsc modified the milestones: Proposal, Go1.6Early Oct 24, 2015
@davecheney
Copy link
Contributor

~ is a shellism, once the program (not just a go program) gets hold of the
values, they will have been expanded by the shell (unless escaped).

This proposal is about trying to make ~ expansion happen in the case where
the shell hasn't been able to do it. I think we should do the opposite and
fail early if ~ has leaked into GOPATH by accident.

On Sat, 24 Oct 2015, 13:55 Russ Cox notifications@github.com wrote:

The possible problems I expect on Windows are subtle (remember that ~ is
how Windows shortens long path names to 8.3 format). "Test it once and ship
it" is NOT okay.

It may be okay to accept ~ only at the beginning of a path element.


Reply to this email directly or view it on GitHub
#9193 (comment).

@minux
Copy link
Member

minux commented Oct 24, 2015 via email

@rsc rsc changed the title proposal: support ~ in import paths proposal: cmd/go: support ~ in import paths Oct 24, 2015
@alexbrainman
Copy link
Member

I don't see why ~ wouldn't work in windows paths:

C:\a>dir
 Volume in drive C has no label.
 Volume Serial Number is 1021-46BD

 Directory of C:\a

24/10/2015  07:14 PM    <DIR>          .
24/10/2015  07:14 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)   4,800,569,344 bytes free

C:\a>echo > ~file

C:\a>echo > file~

C:\a>echo > fi~le

C:\a>echo > ~~~

C:\a>mkdir ~dir

C:\a>mkdir dir~

C:\a>mkdir d~ir

C:\a>mkdir ~~~~

C:\a>mkdir ~~~
A subdirectory or file ~~~ already exists.

C:\a>dir
 Volume in drive C has no label.
 Volume Serial Number is 1021-46BD

 Directory of C:\a

24/10/2015  07:15 PM    <DIR>          .
24/10/2015  07:15 PM    <DIR>          ..
24/10/2015  07:15 PM    <DIR>          dir~
24/10/2015  07:15 PM    <DIR>          d~ir
24/10/2015  07:15 PM                13 file~
24/10/2015  07:15 PM                13 fi~le
24/10/2015  07:15 PM    <DIR>          ~dir
24/10/2015  07:15 PM                13 ~file
24/10/2015  07:15 PM                13 ~~~
24/10/2015  07:15 PM    <DIR>          ~~~~
               4 File(s)             52 bytes
               6 Dir(s)   4,800,565,248 bytes free

C:\a>del file~

C:\a>rmdir dir~

C:\a>

Alex

@rsc
Copy link
Contributor

rsc commented Oct 29, 2015

@davecheney, are you sure this is about shell expansion? The initial report says go get -d gitserver/~user/repo.git, and shell expansion would not apply to a ~ unless it appeared at the beginning of an argument.

I thought this proposal was about supporting git servers that use the literal substring /~user/ in their git URLs. For example I thought launchpad.net did this, and in fact such examples are in our docs:

Launchpad (Bazaar)

    import "launchpad.net/project"
    import "launchpad.net/project/series"
    import "launchpad.net/project/series/sub/directory"

    import "launchpad.net/~user/project/branch"
    import "launchpad.net/~user/project/branch/sub/directory"

I don't have bzr installed and I don't know of any launchpad users to try looking for code. Can someone check what happens if you try to go get a launchpad.net/~user path?

If it doesn't work, we should fix that. We can do that by allowing ~ as the first character of a path element, but no in general.

@alexbrainman, what concerns me about Windows paths is the ambiguity it might introduce. It's true that if you create paths with ~ in them you can get to them, but on most systems you can also, for example, type "c:\progra~1" instead of "c:\program files", and it's that access to shortened names that I want to disallow.

@alexbrainman
Copy link
Member

I hear you @rsc. This program https://play.golang.org/p/PDKP6ZfV0X fails with:

C:\>u:\test
shortname="C:\\DOCUME~1\\brainman\\LOCALS~1\\Temp\\ALEX06~1\\DIRECT~1"
2015/10/30 10:30:22 mkdir C:\DOCUME~1\brainman\LOCALS~1\Temp\ALEX06~1\DIRECT~1: Cannot create a file when that file already exists.

C:\>```

Alex

@rsc
Copy link
Contributor

rsc commented Oct 30, 2015

@rogpeppe or @niemeyer, do either of you have or know of Go code on launchpad.net/~user repos? Can you check whether they work with go get today? Thanks.

@rsc
Copy link
Contributor

rsc commented Nov 5, 2015

This proposal is accepted provided it's only about leading ~ in path elements. I thought that worked already, and there are examples in the go command docs saying it should work, so that seems pretty unobjectionable. Would still like to hear whether it actually works.

@rsc rsc changed the title proposal: cmd/go: support ~ in import paths cmd/go: support ~ in import paths Nov 5, 2015
@rsc rsc added this to the Go1.6 milestone Nov 5, 2015
@rsc rsc removed this from the Proposal milestone Nov 5, 2015
@gopherbot
Copy link
Author

CL https://golang.org/cl/17952 mentions this issue.

@rsc rsc closed this as completed in 0d641c7 Dec 17, 2015
@golang golang locked and limited conversation to collaborators Dec 29, 2016
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

9 participants