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

cmd/go: unable to pull from private Bitbucket Server repository (adding "scm" to url) #35808

Open
flowchartsman opened this issue Nov 24, 2019 · 5 comments

Comments

@flowchartsman
Copy link

@flowchartsman flowchartsman commented Nov 24, 2019

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

$ go version
go version go1.13.1 darwin/amd64

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/awalker/Library/Caches/go-build"
GOENV="/Users/awalker/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/awalker/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/awalker/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/awalker/opt/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/awalker/devel/go/newmodule/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2m/6j_wq4c55rl4l1kvdp5v1g7m0000gn/T/go-build455928014=/tmp/go-build -gno-record-gcc-switches -fno-common

What did you do?

New module depending on private server "stash.foo.bar/proj/foo"

go build

What did you expect to see?

Built module successfully

What did you see instead?

$ go build
build stash.foo.bar/proj/newmodule/cmd/test: cannot load stash.foo.bar/proj/foo: git ls-remote -q https://stash.foo.bar/scm/proj/foo.git in /Users/awalker/go/pkg/mod/cache/vcs/fd6ad5b1d9e53235a680c478180100b6e660d83a6d9d2b39ae8ab7edc8542761: exit status 128:
        Repository not found
        The requested repository does not exist, or you do not have permission to access it.
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

Git is configured like the following:

[url "ssh://git@stash.foo.bar:7999/"]
    insteadOf = https://stash.foo.bar/

Appears to stem from spurious scm added to the ls-remote command:

$ git ls-remote -q https://stash.foo.bar/scm/proj/foo.git
Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Correcting it to remove the 'scm', I get:

$ git ls-remote -q https://stash.foo.bar/proj/foo.git
e881543b746ddd207026bbd896fbf5bbbd576ef4        HEAD
e881543b746ddd207026bbd896fbf5bbbd576ef4        refs/heads/master
@flowchartsman

This comment has been minimized.

Copy link
Author

@flowchartsman flowchartsman commented Nov 24, 2019

Update, changing the relevant section in .gitconfig to the following fixed it, but it is unclear why:

[url "ssh://git@stash.foo.bar:7999/"]
    insteadOf = https://stash.foo.bar/scm/
$ GOPRIVATE=stash.foo.bar go build
go: finding stash.foo.bar/proj/foo latest
go: downloading stash.foo.bar/proj/foo v0.0.0-20191123201619-e881543b746d
go: extracting stash.foo.bar/proj/foo v0.0.0-20191123201619-e881543b746d

¯_(ツ)_/¯

@flowchartsman flowchartsman changed the title unable to pull from private bitbucket repository (adding "scm" to url) unable to pull from private stash repository (adding "scm" to url) Nov 24, 2019
@flowchartsman flowchartsman changed the title unable to pull from private stash repository (adding "scm" to url) unable to pull from private bitbucket/stash repository (adding "scm" to url) Nov 24, 2019
@flowchartsman

This comment has been minimized.

Copy link
Author

@flowchartsman flowchartsman commented Nov 24, 2019

Still attempting to dig into this. So it seems as though my internal VCS is actually "Bitbucket Server v5.16.10", while the current version is "6.8.0", so the "scm" portion of the URL might be something introduced in a later version (still trying to bisect). Unsure what the correct answer is here, and whether or not the insteadOf workaround is just something I'm going to have to live with or whether there is a better way to deal with it. If anyone with more experience has any guidance, please let me know.

@flowchartsman

This comment has been minimized.

Copy link
Author

@flowchartsman flowchartsman commented Nov 24, 2019

Related: https://jira.atlassian.com/browse/BSERV-8255 Seems there is a discrepancy between the https urls and the ssh ones, with the former requiring them and the latter not? I'm unclear on whether or not this is configurable.

@flowchartsman flowchartsman changed the title unable to pull from private bitbucket/stash repository (adding "scm" to url) unable to pull from private Bitbucket Server repository (adding "scm" to url) Nov 24, 2019
@dmitshur dmitshur changed the title unable to pull from private Bitbucket Server repository (adding "scm" to url) cmd/go: unable to pull from private Bitbucket Server repository (adding "scm" to url) Nov 26, 2019
@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Nov 26, 2019

@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Nov 26, 2019

So it seems as though my internal VCS is actually "Bitbucket Server v5.16.10",

I'm not very familiar with the Bitbucket Server, but does it have any documentation for how to access private Go repositories on it with the go command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.