Skip to content

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

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

Closed
grecinto opened this issue Jan 22, 2025 · 22 comments
Labels
BugReport Issues describing a possible bug in the Go implementation.

Comments

@grecinto
Copy link

grecinto commented Jan 22, 2025

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

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Jan 22, 2025
@seankhliao
Copy link
Member

gitlab works without the .git suffixes (example https://gitlab.com/gitlab-org/gitlab/-/issues/29629). if you have problems, it's because of other reasons.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2025
@grecinto
Copy link
Author

gitlab works without the .git suffixes (example https://gitlab.com/gitlab-org/gitlab/-/issues/29629). if you have problems, it's because of other reasons.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

That thread in your shared link discusses "git clone" which I also specified works. "go get" or "go mod tidy" is the one not working, discussed by this bug report. I am re-opening the case.

@seankhliao
Copy link
Member

seankhliao commented Jan 22, 2025

go invokes git, git operates on the repo, and git + gitlab works without the .git suffix.

@grecinto
Copy link
Author

grecinto commented Jan 22, 2025

go invokes git, git operates on the repo, and git + gitlab works without the .git suffix.

Not true, here is the output of running "go get -x" (prints out each step):

$ 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

Obviously, the line: git ls-remote https://foobar.com/abc/mdx
is showing that the "go get" truncates the .git suffix. it should be issuing this cmd instead:

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

AND running git commands on URLs w/ truncated .git suffix vs gitlab repo is NOT working.

@grecinto
Copy link
Author

Adding this link to provide evidence from other experts that the ".git" suffix is forcing "us" to reimplement the go.mod and .go code files "import statement", and that git + gitlab does NOT work without the ".git" suffix:

https://stackoverflow.com/questions/65921916/why-does-go-module-ssh-custom-private-repo-non-github-config-still-request-htt/65925691#65925691

@seankhliao
Copy link
Member

Observe the operation log for go operating on a gitlab repo,
both clones succeed whether or not .git is specified in the url go / git uses.

main » go get -x gitlab.com/seankhliao/testrepo0986
# get https://gitlab.com/?go-get=1
# get https://gitlab.com/seankhliao?go-get=1
# get https://gitlab.com/seankhliao/testrepo0986?go-get=1
# get https://gitlab.com/seankhliao/testrepo0986?go-get=1: 200 OK (0.478s)
mkdir -p /home/user/.data/go/pkg/mod/cache/vcs # git3 https://gitlab.com/seankhliao/testrepo0986.git
# lock /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2.lock
# get https://gitlab.com/?go-get=1: 404 Not Found (0.492s)
mkdir -p /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2 # git3 https://gitlab.com/seankhliao/testrepo0986.git
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git init --bare
# get https://gitlab.com/seankhliao?go-get=1: 404 Not Found (0.500s)
0.007s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git init --bare
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986.git
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986.git
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git ls-remote -q origin
0.661s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git ls-remote -q origin
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git tag -l
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git tag -l
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
1.175s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git for-each-ref --format %(refname) refs/tags --merged 2911186b68fef25330c978656f7fbaa78c85b431
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git for-each-ref --format %(refname) refs/tags --merged 2911186b68fef25330c978656f7fbaa78c85b431
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.005s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
go: downloading gitlab.com/seankhliao/testrepo0986 v0.0.0-20250122194836-2911186b68fe
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.002s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ 2911186b68fef25330c978656f7fbaa78c85b431
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/e389f9ea3583eed32796f349e79d64a9a5aa77e43767e710ee4b5fc3827bb8f2; git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ 2911186b68fef25330c978656f7fbaa78c85b431
go: added gitlab.com/seankhliao/testrepo0986 v0.0.0-20250122194836-2911186b68fe
main » go get -x gitlab.com/seankhliao/testrepo0986.git
# get https://gitlab.com/?go-get=1
# get https://gitlab.com/seankhliao?go-get=1
cd /home/user/.data/go/pkg/mod
git ls-remote https://gitlab.com/seankhliao/testrepo0986
# get https://gitlab.com/seankhliao?go-get=1: Get "https://gitlab.com/seankhliao?go-get=1": EOF
# get https://gitlab.com/?go-get=1: 404 Not Found (0.574s)
mkdir -p /home/user/.data/go/pkg/mod/cache/vcs # git3 https://gitlab.com/seankhliao/testrepo0986
# lock /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266.lock
mkdir -p /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266 # git3 https://gitlab.com/seankhliao/testrepo0986
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git init --bare
0.021s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git init --bare
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986
0.005s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git ls-remote -q origin
1.077s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git ls-remote -q origin
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git tag -l
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git tag -l
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
1.353s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git for-each-ref --format %(refname) refs/tags --merged 2911186b68fef25330c978656f7fbaa78c85b431
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git for-each-ref --format %(refname) refs/tags --merged 2911186b68fef25330c978656f7fbaa78c85b431
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.004s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
go: downloading gitlab.com/seankhliao/testrepo0986.git v0.0.0-20250122194836-2911186b68fe
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ 2911186b68fef25330c978656f7fbaa78c85b431
0.005s # cd /home/user/.data/go/pkg/mod/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ 2911186b68fef25330c978656f7fbaa78c85b431
go: gitlab.com/seankhliao/testrepo0986.git@upgrade (v0.0.0-20250122194836-2911186b68fe) requires gitlab.com/seankhliao/[email protected]: parsing go.mod:
	module declares its path as: gitlab.com/seankhliao/testrepo0986
	       but was required as: gitlab.com/seankhliao/testrepo0986.git

@grecinto
Copy link
Author

grecinto commented Jan 22, 2025

You are feeding it with URL & a public gitlab repo, that is a different use-case. Use my use-case, where you issue "go get -x" so you take go.mod (of current folder) contents and let go get compose the URLs in discovery. Also, I specified private gitlab repo, not public. The public repo approach, it went to "proxy go org" way and can download from there, that is a different use-case than "private" gitlab repo.

The go.mod should contain "replace" statement such as:
replace (github.com/abc/mdx v1.1.1 => gitlabce.com/abc/mdx.git v1.1.1)

And in gitlabce.com, you have a repo abc/mdx.git with (release) tag v1.1.1.

@seankhliao
Copy link
Member

Go only operates on module paths, not urls.

main » go get -x
cd /tmp/tmp.00SddOOFbz
git ls-remote https://gitlab.com/seankhliao/testrepo0986
mkdir -p /tmp/tmp.00SddOOFbz/cache/vcs # git3 https://gitlab.com/seankhliao/testrepo0986
# lock /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266.lock
mkdir -p /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266 # git3 https://gitlab.com/seankhliao/testrepo0986
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git init --bare
0.005s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git init --bare
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986
0.003s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git remote add origin -- https://gitlab.com/seankhliao/testrepo0986
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
0.004s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fe --
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git ls-remote -q origin
0.909s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git ls-remote -q origin
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git tag -l
0.003s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git tag -l
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
2.362s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c protocol.version=2 fetch -f --depth=1 origin 2911186b68fef25330c978656f7fbaa78c85b431:refs/dummy
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
0.003s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 2911186b68fef25330c978656f7fbaa78c85b431 --
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.003s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
0.004s # cd /tmp/tmp.00SddOOFbz/cache/vcs/b0cf8c2603d192e8e10fd6a59783925327d73e2be0bc4016076c355935231266; git cat-file blob 2911186b68fef25330c978656f7fbaa78c85b431:go.mod
go: example.com/[email protected] (replaced by gitlab.com/seankhliao/[email protected]): parsing go.mod:
	module declares its path as: gitlab.com/seankhliao/testrepo0986
	       but was required as: example.com/testrepo0986

main » cat go.mod
module go.seankhliao.com/testrepo0987

go 1.24

require example.com/testrepo0986 v0.0.0 // indirect

replace example.com/testrepo0986 => gitlab.com/seankhliao/testrepo0986.git v0.0.0-20250122194836-2911186b68fe

@grecinto
Copy link
Author

grecinto commented Jan 22, 2025

I am using go 1.23.5 version and I meant module "paths" in this context. I just used the word URL, but technically, a path/URI. Does that work in go 1.23.5? Because 1.24, the one you are using is still not "out", or NOT downloadable from public download sites.

@seankhliao
Copy link
Member

Nothing has changed wrt to invoking mapping module paths for git repos for years.
If you have problems, it's almost certainly misconfiguration on your side, as evidenced by the many projects available on gitlab.

as before, please take troubleshooting your personal setup to a forum.

@grecinto
Copy link
Author

grecinto commented Jan 22, 2025

Another thing, as I originally mentioned, this is a setup where I used "reverse proxy" to create an HTTPs endpoint in front of HTTP endpoint in gitlab repo.

So, gitlabce.com/abc/mdx.git is actually resolving to: https://gitlabce.com/abc/mdx.git
Which in turn, internally gets relayed by the "reverse proxy" to the http://gitlabce.com/abc/mdx.git

So, if "go get" truncates the ".git" suffix, then it may behave differently than if gitlab repo is exposed as HTTPs using its HTTPs "feature".

Is this setup supported? But isn't it, that we want this to work too? I mean, this is also a valid use-case. For example, gitlab is a service hosted in another service and which, gitlab built-in HTTPs feature is harder to impossible to be setup because of such service under a service layout(TLS certificates for HTTPs require a real host!), then, it will not work. It is a bug in this case, right?

I mentioned this, that this is the layout of the setup in the original report.

You may be running "go get -x" vs a gitlab repo that is on an HTTPs endpoint natively or directly exposed by gitlab(no reverse proxy!). That may be a different "use-case" altogether.

Problem is, if this HTTPs endpoint via "reverse proxy" is not supported, then, IT shops are being forced to implement special hardware/VM for the gitlab so its HTTPs feature for repositories will work w/ "go get"(& go mod tidy).

@grecinto
Copy link
Author

@seankhliao I am re-opening this bug report & emphasizing that the issue is on HTTPs endpoint in Gitlab where one uses a reverse proxy to map HTTPs to HTTP gitlab repository.

"go get"(or go mod tidy) should be able to resolve correctly a module path that ends w/ .git. And the benefits why it is important, ability to use Gitlab as service within a service, which Gitlab can't be given its own network identity & thus, usage of "reverse proxy" to create an HTTPs gitlab module endpoint can be very convenient, life saver in this situation.

@seankhliao
Copy link
Member

seankhliao commented Jan 24, 2025

Note that gitlab also returns go-import meta tags. a .git suffix is not necessary at all.

And if you break gitlab redirects, that's a you / gitlab problem.

@grecinto
Copy link
Author

grecinto commented Jan 24, 2025

It boils down to use-case. Right now, use-case of using reverse-proxy to expose an HTTPs gitlab module repo endpoint is not supported. Because such does not return meta tags making the go get discovery to work.

But why do you need that, when go get was given full module path that works? Decision to not support the full path (.git suffix remove) seems a bug from (usage) dev standpoint. Unless there is another unspoken/undocumented reason like security.

IT shops are being forced to implement provisioning gitlab with enabled HTTPs (on repo) feature.

@grecinto
Copy link
Author

grecinto commented Jan 24, 2025

Can we reopen this issue because it prevents usage of Gitlab HTTP module endpoint surfaced as HTTPs via reverse proxy, a real world valid setup?

Example in my case, I am blocked & team is forced to provision hardware & software for the supported case.

Many other shops faced/will face the same scenario. But it is a simple feature support not to truncate “.git” suffix. git commands work on the full module path. Thus isolating it to be a bug in “go get”.

@seankhliao

@seankhliao
Copy link
Member

I believe changing the url go uses is a non-starter.
It would be a breaking change and would break common configurations like:

[url "ssh://[email protected]/"]
    insteadOf = https://example.com/

generally, git hosts are flexible in redirecting http paths to one that works, but git/ssh may directly use paths on the filesystem and offer no such flexibility.

@grecinto
Copy link
Author

grecinto commented Jan 24, 2025

The “.git” suffix is a suffix which does not break your example, as that is a feature applied on prefix. Prefix is before the module repo name in its module path.

One does not include suffix .git typically, unless it is intended. Specific use in “replace” statements in go.mod.

Afaik, it is a targeted edge case. Removal of it(ending or last part, “.git”) in go get in this specific condition described(replace) does look like a bug, bcos if it is intended, why do you decide to override it or does not include it in the list of options tried?

Go get tries https then ssh, but does not try the full mod path? It is easily achieved without breaking anything, on this viewpoint.

@seankhliao
Copy link
Member

if a .git was added to the url, after the rewrite, the url git uses would be ssh://[email protected]/some/repo.git
this may break users as their (bare) git repo on the server is in the directory /some/repo not /some/repo.git.

@grecinto
Copy link
Author

grecinto commented Jan 24, 2025

We are only talking about in https protocol, not in ssh. And in ssh, it does end in .git as well in gitlab.

Plus, developer will not specify .git suffix unless it is what it is. Why will you write it in go.mod with .git suffix if it is resolvable without it?

There is no proposal to automagically add a suffix. Proposal is to add “taking it as it is” the module path, suffix wise.

If I internalize it well, I see the truncation as the bug. You don’t need to truncate the suffix actuallly, simple. And if developer added a suffix when there is not, then that is on us, right?

Your tool should be very simple in dealing with the suffix part.

@mwieczorkiewicz
Copy link

@grecinto - do you have any workaround?

I stumbled across similar issue when trying to build OCI containers with privately hosted modules that are used with replace directive. Interestingly - on macOS it works as intended.

@grecinto
Copy link
Author

grecinto commented Mar 4, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation.
Projects
None yet
Development

No branches or pull requests

4 participants