Vendoring + submodules: go get error

1,197 views
Skip to first unread message

Stephan Dollberg

unread,
Aug 21, 2015, 7:38:40 AM8/21/15
to golang-nuts
Hi,

I am trying to get vendoring working with submodules. While the building part works fine the "go get" part doesn't.

To repro I created a test repo[1] by doing the following: 
 
 - Created a test package and added a submodule via:
 - Committed everything

Now, if I do:


I get the error:


# cd .; git --git-dir=/$GOPATH/src/github.com/StephanDollberg/govendorsubmodulestest/.git submodule update --init --recursive

No submodule mapping found in .gitmodules for path 'vendor/github.com/dgrijalva/jwt-go'

package github.com/StephanDollberg/govendorsubmodulestest: exit status 1


The interesting thing is that if I do a go get -u after that it checks out the submodule correctly. Looking at the error and the source of the go command I think it has to do with --git-dir not working together with the submodule command. 

Is this a bug in go or did I add the submodule incorrectly? I tested it on Mac OSX 10.10.5 with git 2.3.1 and on Windows 10 with git 2.5.

Thanks,
Stephan

Stephan Dollberg

unread,
Sep 3, 2015, 12:22:17 PM9/3/15
to golang-nuts
Hope it's ok to bump.

While looking around I didn't find any another project so far that uses submodules and such I am not sure whether this is a problem of how to add submodules or of the go command side. 

Giulio Iotti

unread,
Sep 8, 2015, 9:28:19 AM9/8/15
to golang-nuts
On Thursday, September 3, 2015 at 6:22:17 PM UTC+2, Stephan Dollberg wrote:
Hope it's ok to bump.

While looking around I didn't find any another project so far that uses submodules and such I am not sure whether this is a problem of how to add submodules or of the go command side. 

Hi Stephan,

Upgrade your git. I can reproduce on one machine with Git 1.7; the option --git-dir is from 1.8 only (and is silently ignored in older versions).

-- 
Giulio Iotti 

Matt Farina

unread,
Sep 8, 2015, 2:01:36 PM9/8/15
to golang-nuts
`go get` doesn't operate on the vendor/ directory. It's only for the $GOPATH. Issues have been filed.

Instead of submodules (or subtrees) I use Glide to manage my vendor/ directory. I'm one of the authors so I'm entirely biased.

Giulio Iotti

unread,
Sep 8, 2015, 2:08:26 PM9/8/15
to golang-nuts
On Tuesday, September 8, 2015 at 9:01:36 PM UTC+3, Matt Farina wrote:
`go get` doesn't operate on the vendor/ directory. It's only for the $GOPATH. Issues have been filed.

Instead of submodules (or subtrees) I use Glide to manage my vendor/ directory. I'm one of the authors so I'm entirely biased.

What I understand he is trying to do is to go get an project containing a vendor/ directory with some git submodules. Git submodules now work[1].

What you say is right, but it's a different case: you cannot go get a package inside a vendor/ directory, but this step was done manually (using git submodules.)


-- 
Giulio Iotti 

Stephan Dollberg

unread,
Sep 8, 2015, 2:09:14 PM9/8/15
to golang-nuts
@Giulio

Thanks for your reply. Are you saying that you got it working with git > 1.7? I tried it with several git versions (2.3, 2.4, 2.5) on OSX, Windows and Linux and couldn't get it working.

@Matt

Maybe this is a misunderstanding but I am not talking about fetching dependencies into /vendor with go get but about the initial checkout of a repository that uses submodules in /vendor.

Giulio Iotti

unread,
Sep 8, 2015, 2:14:37 PM9/8/15
to golang-nuts
On Tuesday, September 8, 2015 at 9:09:14 PM UTC+3, Stephan Dollberg wrote:
@Giulio

Thanks for your reply. Are you saying that you got it working with git > 1.7? I tried it with several git versions (2.3, 2.4, 2.5) on OSX, Windows and Linux and couldn't get it working.

$ GO15VENDOREXPERIMENT=1 go get -u github.com/StephanDollberg/govendorsubmodulestest

You need to also specify -u. Works for me with git 2.1

-- 
Giulio Iotti

Stephan Dollberg

unread,
Sep 8, 2015, 2:17:36 PM9/8/15
to golang-nuts
Does that also work initially (without having the repo already checked out)? Doing -u twice works but the initial checkout is the problem because the git commands that are being executed are different.

Giulio Iotti

unread,
Sep 8, 2015, 2:22:14 PM9/8/15
to golang-nuts
On Tuesday, September 8, 2015 at 9:17:36 PM UTC+3, Stephan Dollberg wrote:
Does that also work initially (without having the repo already checked out)? Doing -u twice works but the initial checkout is the problem because the git commands that are being executed are different.

True, you got me.  I am not sure why... file an issue?

-- 
Giulio Iotti 

Stephan Dollberg

unread,
Sep 9, 2015, 2:31:35 AM9/9/15
to golang-nuts
Yeah, should probably do that. First wanted to cross check. Same behaviour with go 1.5.1.

Peter Waller

unread,
Oct 16, 2015, 11:47:56 AM10/16/15
to Stephan Dollberg, golang-nuts
Hi. Was an issue filed? We just encountered the same. "go get github.com/scraperwiki/hanoverd/cmd/git-prep-directory" fails, but "go get -u github.com/scraperwiki/hanoverd/cmd/git-prep-directory" succeeds.

I understand they should both succeed.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephan Dollberg

unread,
Oct 16, 2015, 12:06:54 PM10/16/15
to golang-nuts, stephan....@gmail.com
Hi Peter,

yes, I filed an issue here: 


Cheers,
Stephan
Reply all
Reply to author
Forward
0 new messages