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 -u for package with submodule vendor: package <VENDOR PACKAGE>: <GIT DIR> exists but is not a directory #17522

Open
tsaikd opened this Issue Oct 20, 2016 · 10 comments

Comments

Projects
None yet
@tsaikd

tsaikd commented Oct 20, 2016

What version of Go are you using (go version)?

go version devel +9a97c3b Mon Oct 17 17:05:39 2016 +0000 linux/amd64
  • In fact, after 9a97c3b will cause this issue, even in the latest ef8e85e [Tue Oct 18 16:38:54 2016 -0700]

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/go-src"
GOTOOLDIR="/go-src/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build210141904=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

go get -u -v github.com/tsaikd/go-get-vendor-submodule-test

What did you expect to see?

response without error message

What did you see instead?

github.com/tsaikd/go-get-vendor-submodule-test (download)
github.com/tsaikd/go-get-vendor-submodule-test/vendor/github.com/golang/example (download)
package github.com/tsaikd/go-get-vendor-submodule-test/vendor/github.com/golang/example/stringutil: /go/src/github.com/tsaikd/go-get-vendor-submodule-test/vendor/github.com/golang/example/.git exists but is not a directory

No problem with 9a97c3b patch it self, but not completely. In src/cmd/go/get.go

go/src/cmd/go/get.go

Lines 419 to 423 in 9a97c3b

meta := filepath.Join(root, "."+vcs.cmd)
st, err := os.Stat(meta)
if err == nil && !st.IsDir() {
return fmt.Errorf("%s exists but is not a directory", meta)
}

func downloadPackage(p *Package) error {
    ...

    meta := filepath.Join(root, "."+vcs.cmd)
    st, err := os.Stat(meta)
    if err == nil && !st.IsDir() {
        return fmt.Errorf("%s exists but is not a directory", meta)
    }

    ...

Should it must to be a directory for meta ?

@quentinmit quentinmit added the NeedsFix label Oct 20, 2016

@quentinmit quentinmit added this to the Go1.8 milestone Oct 20, 2016

@quentinmit

This comment has been minimized.

Contributor

quentinmit commented Oct 20, 2016

@rsc since you just fixed the other half of this

@rsc rsc modified the milestones: Go1.9, Go1.8 Nov 11, 2016

@akerl

This comment has been minimized.

akerl commented Feb 20, 2017

Just ran into this. Is there a workaround, since it looks like 1.8 was released w/o a fix?

@evantbyrne

This comment has been minimized.

evantbyrne commented Feb 22, 2017

@akerl, Ended up getting around this for one of my repositories that stopped working on upgrading to 1.8 by using git submodules to vendor dependencies and avoiding go get entirely. Installing from source is then a matter of cloning with the --recursive flag and then running go install. Ideally it could be done through go get like before, but using git should work in the meantime.

@gopherbot

This comment has been minimized.

gopherbot commented Jul 17, 2017

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

@ldemailly

This comment has been minimized.

ldemailly commented Feb 10, 2018

I'm seeing something very similar too - not sure I quite understand:

$ docker run -ti golang:1.8
root@ea4f09bd961f:/go# go get -u istio.io/fortio
package istio.io/fortio/vendor/golang.org/x/net/context: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/health: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/health/grpc_health_v1: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/reflection: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/github.com/golang/protobuf/proto: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git

note it works fine without -u:

root@ea4f09bd961f:/go# go get istio.io/fortio
root@ea4f09bd961f:/go# 

istio.io/fortio maps to github.com/istio/fortio
vendor in fortio is a submodule

ps: same with go 1.10rc2:

Status: Downloaded newer image for golang:1.10rc2
root@d7edc8d7cfda:/go# go get -u istio.io/fortio
package istio.io/fortio/vendor/golang.org/x/net/context: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/health: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/health/grpc_health_v1: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/google.golang.org/grpc/reflection: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
package istio.io/fortio/vendor/github.com/golang/protobuf/proto: istio.io/fortio is a custom import path for https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is checked out from https://github.com/istio-releases/fortio-vendor.git
@ldemailly

This comment has been minimized.

ldemailly commented Feb 11, 2018

after fixing the vanity url to add something for vendor (which shouldn't be needed... imo):

     <meta name="go-import" content="istio.io/fortio/vendor git https://github.com/istio-releases/fortio-vendor">
     <meta name="go-source" content="istio.io/fortio/vendor     https://github.com/istio-releases/fortio-vendor https://github.com/istio-releases/fortio-vendor/tree/master{/dir} https://github.com/istio-releases/fortio-vendor/blob/master{/dir}/{file}#L{line}">

I now get

$ go get -u istio.io/fortio
package istio.io/fortio/vendor/golang.org/x/net/context: /Users/ldemailly/go/src/istio.io/fortio/vendor/.git exists but is not a directory

ldemailly added a commit to istio/admin-sites that referenced this issue Feb 11, 2018

Adding vendor path
To avoid
package istio.io/fortio/vendor/golang.org/x/net/context:
istio.io/fortio is a custom import path for
https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is
checked out from https://github.com/istio-releases/fortio-vendor.git

But then one gets
golang/go#17522 (comment)
@ldemailly

This comment has been minimized.

ldemailly commented Feb 11, 2018

and with 1.10rc2, different error:

$ docker run -ti golang:1.10rc2
root@453b293b15df:/go# go get -u istio.io/fortio
# cd /go/src/istio.io/fortio/vendor; git pull --ff-only
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

package istio.io/fortio/vendor/golang.org/x/net/context: exit status 1
root@453b293b15df:/go# 
@ldemailly

This comment has been minimized.

ldemailly commented Feb 11, 2018

I tried adding a branch to my submodule but exact same error

root@5ecfa2cf12a8:/go/src/istio.io/fortio# cat .gitmodules 
[submodule "vendor"]
	path = vendor
	url = https://github.com/istio-releases/fortio-vendor.git
	branch = master

ayj added a commit to istio/admin-sites that referenced this issue Feb 12, 2018

Adding vendor path (#50)
To avoid
package istio.io/fortio/vendor/golang.org/x/net/context:
istio.io/fortio is a custom import path for
https://github.com/istio/fortio, but /go/src/istio.io/fortio/vendor is
checked out from https://github.com/istio-releases/fortio-vendor.git

But then one gets
golang/go#17522 (comment)
@ldemailly

This comment has been minimized.

ldemailly commented Feb 13, 2018

cc @bradfitz any chance this can be fixed before 1.10 goes final, or at least in 1.11 ?

@bradfitz

This comment has been minimized.

Member

bradfitz commented Feb 13, 2018

@ldemailly, it's way too late for Go 1.10. Go 1.10 froze over 3 months ago. It's marked for Go 1.11, but it was also marked for Go 1.8, so.... we'll see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment