"go get" fails with private bitbucket repository

11,522 views
Skip to first unread message

Erik Aigner

unread,
Nov 25, 2012, 12:42:12 PM11/25/12
to golan...@googlegroups.com
I'm trying to get the private bitbucket import

    go get bitbucket.org/<user>/<repo>/<package>

to work, but it always seems to fail with

    https://api.bitbucket.org/1.0/repositories/<user>/<repo>: 403 FORBIDDEN

Since bitbucket allows different VCS types, the go get command seems trying to figure out
what repository type it is via the bitbucket api and fails. The strange thing is, that even when
the .git suffix is added to the import path to hint the repository type, it still makes a call to that API.

What can I do to solve this problem? (except moving code over to GitHub)


agl

unread,
Nov 26, 2012, 10:21:02 AM11/26/12
to golan...@googlegroups.com
On Sunday, November 25, 2012 12:42:12 PM UTC-5, Erik Aigner wrote:
I'm trying to get the private bitbucket import

    go get bitbucket.org/<user>/<repo>/<package>

If it's a private repo, perhaps it's not available to the whole world? Do non-private repos work?


Cheers

AGL

Russ Cox

unread,
Nov 26, 2012, 10:41:02 AM11/26/12
to Erik Aigner, golang-nuts
On Sun, Nov 25, 2012 at 12:42 PM, Erik Aigner <aigne...@gmail.com> wrote:
> I'm trying to get the private bitbucket import
>
> go get bitbucket.org/<user>/<repo>/<package>
>
> to work, but it always seems to fail with
>
> https://api.bitbucket.org/1.0/repositories/<user>/<repo>: 403 FORBIDDEN

This is kind of a design error in the go tool. The bitbucket.org
syntax is a special case, really assumed to be public, and we explicit
ignore the .git suffix to avoid having the same package importable
under two different paths. Because there's no authentication in the
https request, bitbucket is rejecting the query about a private repo.
But we need to know the VCS type to do the initial checkout.

A workaround is to do the initial checkout yourself:

mkdir -p $GOPATH/src/bitbucket.org/user/repo
git clone git://bitbucket.org/user/repo $GOPATH/src/bitbucket.org/user/repo

and then 'go get' will work. Sorry I don't have a better answer.

Russ

Erik Aigner

unread,
Nov 26, 2012, 10:44:03 AM11/26/12
to golan...@googlegroups.com, Erik Aigner
Thanks!

Kishore Kumar Vaishnav

unread,
Oct 17, 2014, 8:53:19 PM10/17/14
to golan...@googlegroups.com, aigne...@gmail.com
I followed the steps, but looks like `go get` doesn't does the `git pull` activity... after I cloning the repository initially. Am I doing something wrong.

Tamás Gulácsi

unread,
Oct 18, 2014, 1:56:33 AM10/18/14
to golan...@googlegroups.com
Go get will happily leave the existing checkout there. If you want to update it (git pull), invoke go get with -u.

apa...@gmail.com

unread,
May 12, 2015, 10:04:51 AM5/12/15
to golan...@googlegroups.com, aigne...@gmail.com
I used 
git clone git://bitbucket.org/user/repo $GOPATH/src/bitbucket.org/user/repo 

but i got 

fatal: unable to connect to bitbucket.org:
bitbucket.org[0: 131.103.20.167]: errno=Connection refused
bitbucket.org[1: 131.103.20.168]: errno=Connection refused

then I changed it to


everything work find
Reply all
Reply to author
Forward
0 new messages