-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go get fails for long paths #30623
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
Comments
From Jan Mercl at https://groups.google.com/forum/?pli=1#!topic/golang-nuts/83hUVBGu7rA : Seems like your git repo is just misconfigured. Example https (wrong) config:
Make sure the url item has the right (git) protocol. Example correct config:
Above assumes you have your keys correctly registered at gitlab. |
It looks like you're referring to git remote configuration. I don't think that affects how The workaroundI've been able to get it working, but it's very unintuitive and will force all developers to use ssh transport. My goal is to fetch a go module over ssh located at The first thing I needed to do was to rename the go module from Then I updated my global .gitconfig to rewrite all gitlab requests over HTTPS like so:
Lastly I added import (
"gitlab.com/my-company/my-project/my-subproject/my-important-library.git"
"gitlab.com/my-company/my-project/my-subproject/my-important-library.git/foo"
"gitlab.com/my-company/my-project/my-subproject/my-important-library.git/bar"
) Problems
import (
"gitlab.com/my-company/my-project/my-subproject/my-important-library.git/foo"
"gitlab.com/my-company/my-project/my-subproject/my-public-library/foo" // <- No ".git" postfix!
) Solutions#30304 proposes some solutions to this problem ( Proposal 1 - Make go tool chain smarter in how it selects transport for downloading dependenciesAutomatically try ssh if git clone(?) over https fails. The working protocol could be cached for future requests. Proposal 2 - Override dependency transport for the go tool chainIntroduce a way to override the transport used for different dependencies. Example: Tool chain looks for a file named
If this file is outside the project path or not in VCS, then each developer can override this however they like. It is important that this is configured in the go tool chain and not in git, so that we don't mess up the git tool itself. |
That is exactly #30304, which you've already found. (Note the resolution in #30304 (comment).)
That should not be necessary once #29888 is addressed. |
To address some specific points:
Why force ssh instead of fixing HTTPS?
Any change to the
Don't you need to configure every machine that needs access to a private repo with credentials anyway? |
No, in #30304 both proposals rely on the server to tell go which transport to use. Proposal 1 is a fallback solution and does not rely on the server to select a protocol.
See 26232 comment
I'm not sure if this will be an issue, but if one configure git with
Yes, I guess you're right. It just feels wrong to setup (in my case) additional credentials for go when git is happy to work with the credentials already in place. |
I think the rationale in #30304 (comment) still applies here.
In that comment, you state:
I don't see why either of those is intrinsically the case. GitHub “personal access tokens” can be authorized for repo access only. SSH keys either require a password (that is, a user interaction similar to that required by 2FA), or provide a level of security similar to a passwordless SSH key (if someone has access to your machine's SSH private key, that's just as bad as someone who has access to your machine's HTTPS access token). Given that the practical difference is very slight, it doesn't seem worthwhile to add extra complexity to the |
tl;dr
Background
I have a private/hidden project hosted on GitLab where the URL looks something like this:
gitlab.com/my-company/my-project/my-subproject/my-important-library
Since it's a private repository, there's a need to authenticate. The simplest way is to use SSH with a key pair, as it avoids user interaction. However the go toolchain insists on using HTTPS, possibly due to the way gitlab handles
go-get=1
requests. The docs suggest two approaches to get around this:.netrc
git
into usingssh
instead ofhttps
None of these workarounds seems to work. Aside from that, there are some problems:
Using
.netrc
uses clear text passwords/tokens and it's not possible to use several credentials per host. Using.gitconfig
globally does not allow several credentials per host. Configuring it locally for each project is a possibility. All of these approaches get sort of hidden away and are not very intuitive for anyone who needs to usemy-important-library
. It's also a nightmare to setup a build server.Having lost the
ssh
fight withgit
/go get
/go mod
I tried addingGIT_TERMINAL_PROMPT=1
to my commands like so:GIT_TERMINAL_PROMPT=1 go get gitlab.com/my-company/my-project/my-subproject/my-important-library
GIT_TERMINAL_PROMPT=1 go mod download
This introduced me to a different problem. Seems like
go
can only understand urls in the form<host>/<user>/<library>
.What did you do?
What did you expect to see?
EXIT_CODE=0 and
my-important-library
on diskWhat did you see instead?
Note that the half the url (
/my-subproject/my-important-library
) is missing.System details
The text was updated successfully, but these errors were encountered: