go: cmd/go: go get fails with private bitbucket repositories

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOOS=“linux” GOARCH=“amd64”

What did you do?

I attempted to go get from a private bitbucket repository.

  1. add the following to ~/.gitconfig
[url "git@bitbucket.org:"]
	insteadOf = https://bitbucket.org/
  1. add the following to ~/.ssh/config
Host bitbucket.org
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_bitbucket
  StrictHostKeyChecking no
  1. ensure that a valid ssh key exists for bitbucket, ~/.ssh/id_bitbucket

  2. use go get on a private bitbucket repo with modules enabled

What did you expect to see?

I expected the private repository to be pulled to the appropriate ${GOPATH}/pkg/mod directory.

What did you see instead?

go: bitbucket.org/myprivaterepo/projectname@v0.0.0-20180614180234-a79b05b2ef79: https://api.bitbucket.org/2.0/repositories/myprivaterepo/projectname?fields=scm: 403 Forbidden

In the golang-nuts group, Russ had previous posted that this was an issue and could be resolved by hand. With the advent of modules, manually checking out the correct version and putting it into the correct location becomes way more problematic.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 19
  • Comments: 19 (4 by maintainers)

Most upvoted comments

The answer for whoever coming here from google search.

To setup private bitbucket cloud

git config --global url."git@bitbucket.org:YOUR_COMPANY".insteadOf "https://bitbucket.org/YOUR_COMPANY"

Make sure you have setup SSH key access in bitbucket https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html . Your private key id_rsa file should be in ${HOME}/.ssh/ folder.

I downgraded to 1.12.9 and was able to do a go get on a private Bitbucket repo

Something is not working right with regard to this in 1.13

The answer for whoever coming here for google search.

To setup private bitbucket cloud

git config --global url."git@bitbucket.org:YOUR_COMPANY".insteadOf "https://bitbucket.org/YOUR_COMPANY"

Make sure you have setup SSH key access in bitbucket https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html . Your private key id_rsa file should be in ${HOME}/.ssh/ folder.

I did that same thing after that did this export GOPRIVATE=“bitbucket.org/YOUR_COMPANY” closed the console window, restarted my IDE and it worked, i had tried everything already but i worked for me.

I have a similar issue (I think it is the same) I have reported it here https://github.com/golang/go/issues/34528 (solved)

In Order to be able to help you (and decide if its the same issue as 27344 or need a new related issue), can you complete in the format of this issue details (i.e. What version of Go are you using (go version)? … What operating system and processor architecture are you using (go env)? etc)

Anyone with a workaround that actually works? (sorry for empty comment)

This has been rather painful and I think my next stop is to go back to GOPATH and restore vendoring

Is it possible to have an option to use GOPATH by default and for anything it doesn’t find, then vgo the rest? That way, private repo’s and others like this one could be set up either manually prior to an automated like build.