Skip to content

cmd/go: go get fails when Git repository URL is deeper than 2nd level of nesting #22640

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
akamensky opened this issue Nov 9, 2017 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@akamensky
Copy link

akamensky commented Nov 9, 2017

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

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

YES

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

GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alexey.kamenskiy/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rk/g9b46vzx70g86vhvqtmwtjxw0000gn/T/go-build019027498=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

$ go get internal.gitlab.url.com/group-name/subgroup-name/project-name

What did you expect to see?

Git repository cloned successfully

What did you see instead?

$ go get internal.gitlab.url.com/group-name/subgroup-name/project-name
# cd .; git clone https://internal.gitlab.url.com/group-name/subgroup-name.git /Users/username/go/src/internal.gitlab.url.com/group-name/subgroup-name
Cloning into '/Users/username/go/src/internal.gitlab.url.com/group-name/subgroup-name'...
remote: The project you were looking for could not be found.
fatal: repository 'https:///internal.gitlab.url.com/group-name/subgroup-name.git/' not found
package internal.gitlab.url.com/group-name/subgroup-name/project-name: exit status 128

Comment:

Gitlab (not sure since which version) allows for nested groups. Also it may be not a gitlab, but some other self-hosted Git solution which provides URLs longer than just 1 level of nesting.

Also appending .git to the package name in go get command allows for it to be cloned, however the package name then becomes project-name.git.

@akamensky
Copy link
Author

Currently the workaround for this issue is to do manual clone command, such as:

$ git clone https://internal.gitlab.url.com/group-name/subgroup-name/project-name /Users/username/go/src/internal.gitlab.url.com/group-name/subgroup-name/project-name

@akamensky
Copy link
Author

I think the fix would be to iterate over the nesting levels in order to determine which one is clone-able repository. Such as in this example:

  1. Try to clone https://internal.gitlab.url.com/group-name/subgroup-name/project-name.git
  2. If 1 fails try to clone https://internal.gitlab.url.com/group-name/subgroup-name.git
  3. If 2 fails try to clone https://internal.gitlab.url.com/group-name.git
  4. If 3 fails and that is the top level already, then hard-fail as in the error message I see now.

@bradfitz bradfitz changed the title go-get fails when Git repository URL is deeper than 2nd level of nesting cmd/go: go get fails when Git repository URL is deeper than 2nd level of nesting Nov 9, 2017
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 9, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Nov 9, 2017
@rsc
Copy link
Contributor

rsc commented Nov 10, 2017

The go command is just following the instructions served by the Gitlab web server. It sounds like those instructions are wrong for nested groups. That is, when you run

go get internal.gitlab.url.com/group-name/subgroup-name/project-name

the go command fetches

https://internal.gitlab.url.com/group-name/subgroup-name/project-name?go-get=1

to find out what repo to check out. For example:

$ curl 'https://gitlab.com/yorick-github-import-tests/kubernetes?go-get=1'
<html><head><meta name="go-import" content="gitlab.com/yorick-github-import-tests/kubernetes git https://gitlab.com/yorick-github-import-tests/kubernetes.git" /></head></html>$ 

It's exciting to see that Gitlab supports Go like this, but it sounds like Gitlab is serving the wrong answers for your unusually-nested repos. You should report this problem to them. If they need more information from us, we're always happy to provide it, but I expect they will be able to see easily what is wrong.

@rsc rsc closed this as completed Nov 10, 2017
@golang golang locked and limited conversation to collaborators Nov 10, 2018
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants