On execution of
go get bitbucket.org/../..
I get this error
yash.jain projectname % go get bitbucket.org/../..
go: bitbucket.org/../..
https://api.bitbucket.org/2.0/repositories/../..?fields=scm: 403 Forbidden
go: error loading module requirements
What I tried
Setup the ssh key (Working as expected, tested by pushing and pulling the code)
Set the go env variables to this:
GOPRIVATE=""
GOPROXY="direct"
GOSUMDB="off"
.gitconfig looks like this
[url "[email protected]:"]
insteadOf = https://bitbucket.org/
[user]
email = [email protected]
name = yashjain
Added keys to ssh-agent
ssh-add -l
ssh-add -k
.ssh/config file looks like this
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa
UseKeychain yes
StrictHostKeyChecking no
Still, I get the same error. Please let me know If I'm doing something wrong.
These are the steps I tried to make it work.
ssh
.GOPRIVATE=bitbucket.org/<orgname>/*
*
is to allow all the repo of the org.
After these 2 steps I am able to import the package.
Note: Sourcetree is only available to Mac and Windows.
Using Commnd Line: For Linux/Mac/Windows:
git config --global url."[email protected]:".insteadOf "https://bitbucket.org/"
GOPRIVATE=bitbucket.org/<orgname>/*
Update
You might receive the 404
error even after above configuration.
Error
reading https://api.bitbucket.org/2.0/repositories/xyz/privaterepo?fields=scm: 404 Not Found
Bitbucket recently update their APIs for private repository and due to which certain golang version breaks.
Users who do not have access to a private repository will receive 404 (not found) response codes instead of 403 (forbidden) response codes to mask the existence of a private repository at a given URL path.
Rolling out these changes will break previous versions of Go due to the fact that the go command relies on a 403 response to fetch repositories hosted on Bitbucket Cloud.
To ensure that you will not run into any issues, update GoLang to the latest version.
- Ensure you are on a supported version of GoLang: 1.18, 1.17, or 1.16.
- If you are using 1.17 or 1.16, ensure you are on the latest patch (1.17.7 or 1.16.14)
This will be in effect from June 1st 2022.
Changes to Bitbucket API Requires Latest Version of Go
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With