Skip to content

go get on private gitlab repository fails with "no secure protocol found for repository" msg #71389

Closed as not planned
@grecinto

Description

@grecinto

Use-case:

  • migrated repository(ies) from GitHub.com to private gitlab repository(ies)
  • setup HTTPs (via a reverse proxy that maps to HTTP) on the endpoint for use w/ git and go build tools
  • use of "replace" statement in go.mod file to repoint to gitlab repo

Problem: gitlab repositories are suffixed with ".git", and since "go get" (or "go mod tidy") is truncating the .git part under this use-case (replace statement), it fails discovery phase

Example, a go.mod having "replace" statement to repoint to new repository location in "gitlab" such as:
replace ( github.com/abc/mdx v1.1.1 => foobar.com/abc/mdx.git v1.1.1 )

"git clone .." command works on this HTTPs Gitlab endpoint.
"go get -x" on the folder having this go.mod fails with the following steps printed out:
$ go get -x
cd /home/grecinto/go/pkg/mod
git ls-remote https://foobar.com/abc/mdx
cd /home/grecinto/go/pkg/mod
git ls-remote git+ssh://foobar.com/abc/mdx

Observation: as mentioned above, "go get" truncates the .git suffix thus, discovery fails.

Impact: Prevents continuity of the migrated to Gitlab private repositories and forces update of the go.mod and golang .go files to use the new gitlab full URL in import statements, a very exhaustive refactor work & forces code to Segway farther from the github.com repositories. Can't use just the "replace" statement to repoint and leave the code as is. What it(replace) is meant for.

it seems quite clear is misconfiguration on your end. please use one of the forums for troubleshooting your setup, the issue tracker is not the appropriate place to do it.

More info, I found out that the "go get" (or go mod tidy in this respect) is truncating the .git suffix when it tries to communicate to the "HTTPs" remote endpoint as it tries to discover and download the module(s).

Running "go get -x" to print out each step command/URL shows this:

$ go get -x
cd /home/grecinto/go/pkg/mod
git ls-remote https://foobar.com/abc/mdx
cd /home/grecinto/go/pkg/mod
git ls-remote git+ssh://foobar.com/abc/mdx

** I am ready to open an issue on this .git suffix being truncated (after next few hrs or tomorrow morning). Because it, the ".git" suffix, should be taken as is.
Here is the problematic line/step where .git suffix was being truncated:

git ls-remote https://foobar.com/abc/mdx

This should be:

git ls-remote https://foobar.com/abc/mdx.git

as specified in go.mod, from the "replace statement" like this:

replace (
	github.com/abc/mdx v1.1.1 => foobar.com/abc/mdx.git v1.1.1
)

Originally posted by @grecinto in #71317

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions