-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: confusing behavior with ~ in path #4140
Labels
Milestone
Comments
GOPATH will not do ~ expansion. Your claim that "POSIX systems" do this is false. Only bash does this, and we can't possibly keep up with all the magic that bash does. If you have an Ubuntu system, try dash or ksh or pdksh and you'll see that ~ expansion within the variable is quite uncommon. Status changed to Unfortunate. |
The link describes tilde expansion as a property of the shell input syntax. Instead of writing GOPATH="~/go:~/go_mine" you should write GOPATH=~/go:~/go_mine and then the shell will expand the ~ when creating the environment variable. This already works, because it doesn't have anything to do with the go command. What you asked for in this issue is to be able to write the quoted version, creating an environment variable that itself contains ~, and force every program that looks at the environment variable to apply the tilde expansion itself. That is not required by POSIX, and it is not done by any shell I could find, except bash, which does everything. Russ |
Dropping the quotes is good enough for me. Can we get an example and a note about tilde expansion not working inside the quotes on this page: http://golang.org/doc/code.html ? |
I don't believe the page should or needs to say anything about tilde expansion not working inside quotes, especially given that it does not use either one in the examples. I'm sorry you ran into trouble, but tilde expansion pretty much never works inside quotes. This is a fact of Unix, not of Go. (Bash's $PATH interpretation is the anomaly here.) |
Is it possible to at least surface this error more clearly? As a newcomer using `go get` to try out gotour - it appears that Go fails to create the directory structure in GOPATH, but the first and only sign of this is when hg (in this case) tries to clone a repo into the expanded path: dan@dan-MBP ~/projects/personal $ mkdir golang dan@dan-MBP ~/projects/personal $ export GOPATH="~/projects/personal/golang" dan@dan-MBP ~/projects/personal $ go get -v -x code.google.com/p/go-tour/gotour code.google.com/p/go-tour (download) cd . hg clone -U https://code.google.com/p/go-tour ~/projects/personal/golang/src/code.google.com/p/go-tour # cd .; hg clone -U https://code.google.com/p/go-tour ~/projects/personal/golang/src/code.google.com/p/go-tour abort: No such file or directory: /home/dan/projects/personal/golang/src/code.google.com/p/go-tour/.hg package code.google.com/p/go-tour/gotour: exit status 255 |
The output in comment 8 is mysterious indeed. Let's at least make it clearer what is happening. I would hope that since the first (only) directory in $GOPATH does not exist, we should give an error about that instead of trying to invoke hg. Labels changed: added priority-later, go1.1, removed priority-triage. Status changed to Accepted. |
On my Ubuntu system setting GOPATH="~/foobar" leads to some weird behaviour. With the example above it seems the go tool creates $HOME/~/foobar/src/code.google.com/p, which seems like the right thing to do (although slightly unexpected to some people...) if you are not expanding the ~. However as in the example above it when it calls the mercurial command: hg clone -U https://code.google.com/p/go-tour ~/foobar/src/code.google.com/p/go-tour the error message is: abort: No such file or directory: /home/kamil/foobar/src/code.google.com/p/go-tour/.hg which seems to imply that Mercurial does its own tilde expansion and so the paths don't match. |
This issue was closed by revision 8b6534b. Status changed to Fixed. |
This issue was closed by revision ffbcd89. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by stefantalpalaru:
The text was updated successfully, but these errors were encountered: