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: go get fails when directory command launched from gets deleted #14093

Closed
abraithwaite opened this issue Jan 26, 2016 · 9 comments
Closed
Milestone

Comments

@abraithwaite
Copy link
Contributor

$ cd /tmp
$ mkdir asdf
$ cd asdf
$ go get  github.com/influxdata/telegraf &
$ cd ../ && rmdir asdf
# cd .; git clone https://github.com/influxdb/influxdb /home/jessie/Projects/golang/src/github.com/influxdb/influxdb
Cloning into '/home/jessie/Projects/golang/src/github.com/influxdb/influxdb'...
fatal: Unable to read current working directory: No such file or directory
fatal: remote did not send all necessary objects
package github.com/influxdb/influxdb/models: exit status 128
# cd .; git clone https://github.com/stretchr/testify /home/jessie/Projects/golang/src/github.com/stretchr/testify
fatal: Could not get current working directory: No such file or directory
package github.com/stretchr/testify/mock: exit status 128
# cd .; git clone https://github.com/naoina/toml /home/jessie/Projects/golang/src/github.com/naoina/toml
fatal: Could not get current working directory: No such file or directory
package github.com/naoina/toml/ast: exit status 128
$ go version
go version go1.5.3 linux/amd64

Since the directory is not in the $GOPATH/ tree, I did not expect any errors. It's pretty minor but worth mentioning if others run into it.

@davecheney
Copy link
Contributor

You start go get in the background, then while it is running cd up one directory and delete the CWD that git (forked from go get) is running in.

I understand that go get will be checking out into a different location, but I don't think it is unreasonable for git to assume that it's cwd will remain valid while it's doing a checkout.

I don't believe that there is anything to fix in the go tool for the bug you've reported, but I get a feeling that this is a reproduction of a different issue that you're trying to solve. Can you explain more about how you discovered this issue.

@abraithwaite
Copy link
Contributor Author

Sure thing. I accidentally cloned a repo to the wrong location instead of using go get and when I realized this, I used go get instead (in the repo I accidentally cloned) to fetch the repo into my GOPATH. Meanwhile in another terminal I decided to clean up the mis-cloned repo, resulting in this error.

@rakyll
Copy link
Contributor

rakyll commented Jan 26, 2016

git is looking for the cwd in order to convert the relative paths to absolute. In the case of go get, we are already working with absolute paths. If the fix takes only setting an env variable such as GIT_DIR, we don't have to expose the reported limitation to the go-get users. Having said that, I haven't yet find a quick fix.

@rakyll rakyll added this to the Unplanned milestone Jan 26, 2016
@davecheney
Copy link
Contributor

@rakyll go get forks git in the current working directory. It could equally fork git in $GOPATH/src or another location that should exist.

Having said that, I'm unconvinced this is a bug or should be fixed. If you don't want git to complain that the working directory is missing, don't delete it behind git's back.

@rakyll
Copy link
Contributor

rakyll commented Jan 26, 2016

@davecheney To be more clear, I don't understand why go get is cloning in the current directory. go get is a tool to download packages to a certain destination that is not tied to the cwd. I am not quite convinced the current case shouldn't be improved even though I'd say it is not critical enough to care.

@davecheney
Copy link
Contributor

Go get isn't cloning in the current directory, git is, because the go tool
didn't change the directory to anything else yet. I'm sure we can fix that.

On Tue, Jan 26, 2016 at 1:54 PM, Burcu Dogan notifications@github.com
wrote:

@davecheney https://github.com/davecheney To be more clear, I don't
understand why go get is cloning in the current directory. go get is a tool
to download packages to a certain destination that is not tied to the cwd.
I am not quite convinced the current case shouldn't be improved even though
I'd say it is not critical enough to care.


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

@rakyll
Copy link
Contributor

rakyll commented Jan 26, 2016

Go get isn't cloning in the current directory, git is,

Sorry for the implicit wording, this is what I meant above. I am talking about cd'ing into GOPATH (or setting an env variable if possible) to make git clone in a directory that makes sense.

@davecheney
Copy link
Contributor

Sounds good to me.

On Tue, Jan 26, 2016 at 2:15 PM, Burcu Dogan notifications@github.com
wrote:

Go get isn't cloning in the current directory, git is,

Sorry for the implicit wording, this is what I meant above. I am talking
about cd'ing into GOPATH (or setting an env variable if possible) to make
git clone in a directory that makes sense.


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

@rakyll rakyll modified the milestones: Go1.7, Unplanned Feb 5, 2016
@rsc rsc modified the milestones: Go1.8, Go1.7 May 17, 2016
@quentinmit
Copy link
Contributor

I don't think it's worth putting a workaround in here; many Unix programs including "go get" become unhappy if their working directory goes away while they are running. "Don't do that."

@golang golang locked and limited conversation to collaborators Oct 6, 2017
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

6 participants