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

go/build: fail to find vendors in nested projects outside GOPATH #17264

Closed
mcandre opened this issue Sep 28, 2016 · 9 comments
Closed

go/build: fail to find vendors in nested projects outside GOPATH #17264

mcandre opened this issue Sep 28, 2016 · 9 comments

Comments

@mcandre
Copy link

mcandre commented Sep 28, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7 windows/amd64

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\andrew\go
set GORACE=
set GOROOT=C:\tools\go1.7
set GOTOOLDIR=C:\tools\go1.7\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\andrew\AppData\Local\Temp\go-build262609422=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1

What did you do?

I was able to successfully vendor my dependencies via git submodules in a project called https://github.com/mcandre/go-ios7crypt. However, when I try to do this in my ddg project https://github.com/mcandre/mcandre/tree/master/go/ddg, neither go get nor go build work.

What did you expect to see?

I expect the go get and go build commands to work for ddg, as they do for go-ios7crypt.

What did you see instead?

  • go get silently fails.
  • go build complains that it fails to find the vendored dependencies.
@freeformz
Copy link

Please include the entire transcript of what didn't work.

FWIW: It works for me:

$ go get -u -d github.com/mcandre/mcandre/go/ddg
$ cd ~/go/src/github.com/mcandre/mcandre/go/ddg
$ go install -v .
github.com/mcandre/mcandre/go/ddg/vendor/github.com/skratchdot/open-golang/open
github.com/mcandre/mcandre/go/ddg
$ git submodule
 75fb7ed4208cf72d323d7d02fd1a5964a7a9073c vendor/github.com/skratchdot/open-golang (heads/master)
$ rm -rf ~/go/pkg/darwin_amd64/github.com/mcandre
$ go build -v .
github.com/mcandre/mcandre/go/ddg/vendor/github.com/skratchdot/open-golang/open
github.com/mcandre/mcandre/go/ddg
$ cd ~/go/github.com
$ rm -rf mcandre ~/go/bin/ddg
$ go get -v github.com/mcandre/mcandre/go/ddg
github.com/mcandre/mcandre/go/ddg/vendor/github.com/skratchdot/open-golang/open
github.com/mcandre/mcandre/go/ddg
$ ls ~/go/bin/ddg
/Users/emuller/go/bin/ddg

@mcandre
Copy link
Author

mcandre commented Sep 28, 2016

go get github.com/mcandre/mcandre/go/ddg/... successfully builds and installs the ddg binary in Command Prompt, after I manually delete all references to github.com/mcandre in my GOPATH bin, pkg, and src directories.

However, neither go install -v . nor go build -v . work with a simple git clone of github.com/mcandre/mcandre (go/ddg folder).

Trace:

PS> git clone git@github.com:mcandre/mcandre.git
PS> cd mcandre\go\ddg
PS> go install -v .
main.go:4:2: cannot find package "github.com/skratchdot/open-golang/open" in any of:
        C:\tools\go1.7\src\github.com\skratchdot\open-golang\open (from $GOROOT)
        C:\Users\andrew\go\src\github.com\skratchdot\open-golang\open (from $GOPATH)
PS> go build -v .
main.go:4:2: cannot find package "github.com/skratchdot/open-golang/open" in any of:
        C:\tools\go1.7\src\github.com\skratchdot\open-golang\open (from $GOROOT)
        C:\Users\andrew\go\src\github.com\skratchdot\open-golang\open (from $GOPATH)

@freeformz
Copy link

git clone does not restore submodules.

$ cd ~/go/src/github.com/mcandre
$ rm -rf mcandre
$ git clone https://github.com/mcandre/mcandre
Cloning into 'mcandre'...
remote: Counting objects: 12262, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 12262 (delta 3), reused 0 (delta 0), pack-reused 12249
Receiving objects: 100% (12262/12262), 4.31 MiB | 601.00 KiB/s, done.
Resolving deltas: 100% (5794/5794), done.
$ git submodule init
Submodule 'go/ddg/vendor/github.com/skratchdot/open-golang' (https://github.com/skratchdot/open-golang.git) registered for path 'go/ddg/go/ddg/vendor/github.com/skratchdot/open-golang'
$ git submodule update
Cloning into '/Users/emuller/go/src/github.com/mcandre/mcandre/go/ddg/vendor/github.com/skratchdot/open-golang'...
Submodule path 'vendor/github.com/skratchdot/open-golang': checked out '75fb7ed4208cf72d323d7d02fd1a5964a7a9073c'
$ go install -v .
github.com/mcandre/mcandre/go/ddg/vendor/github.com/skratchdot/open-golang/open
github.com/mcandre/mcandre/go/ddg

AFAICT, This isn't a go issue and can be closed.

@mcandre
Copy link
Author

mcandre commented Sep 29, 2016

Even when I git submodule init && git submodule update, go get and go build still fail on my machine.

@freeformz
Copy link

@mcandre with the same error(s) ?

@mcandre
Copy link
Author

mcandre commented Sep 30, 2016

yes

@freeformz
Copy link

@mcandre Are you cloning into %GOPATH%/src/github.com/mcandre ? If not then it won't work.

@mcandre
Copy link
Author

mcandre commented Oct 1, 2016

I'm not cloning into GOPATH for github.com/mcandre/mcandre, yet I don't
need to do this for github.com/mcandre/go-ios7crypt, and yet that one
still works for some reason.

On Fri, Sep 30, 2016 at 4:56 PM, Edward Muller notifications@github.com
wrote:

@mcandre https://github.com/mcandre Are you cloning into %GOPATH%/src/
github.com/mcandre ? If not then it won't work.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#17264 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAUxNwcpTBaMlFNybZR2CjRWu13BE-aks5qvYWjgaJpZM4KI-WY
.

Cheers,
Andrew

@quentinmit
Copy link
Contributor

I think this is a dupe of #14566. vendor directories are currently ignored if they are not under GOPATH; that issue tracks fixing this.

@quentinmit quentinmit changed the title go get/build fail to find vendors in nested projects go/build: fail to find vendors in nested projects outside GOPATH Oct 3, 2016
@golang golang locked and limited conversation to collaborators Oct 3, 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

4 participants