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: improve error message if remote repo does not support https #27088

Closed
shoenig opened this issue Aug 19, 2018 · 13 comments
Closed

cmd/go: improve error message if remote repo does not support https #27088

shoenig opened this issue Aug 19, 2018 · 13 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@shoenig
Copy link
Contributor

shoenig commented Aug 19, 2018

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

[k9 libconfig (master)] $ go version
go version devel +bf80e3b564 Sat Aug 18 18:23:06 2018 +0000 linux/amd64

What did you do?

With go1.11, run go build with modules and got unexpected "unknown revision" errors.
First, the go.mod file:

[k9 libops (master)] $ cat go.mod 
module code.corp.indeed.com/gophers/libops

require (
	code.corp.indeed.com/gophers/3rdparty v0.0.1
	code.corp.indeed.com/gophers/libconfig v0.0.1
)

replace (
	code.corp.indeed.com/gophers/3rdparty => ../../gophers/3rdparty
	code.corp.indeed.com/gophers/libconfig => ../../gophers/libconfig
)

Now let's try to build it:

[k9 libops (master)] $ go build
go: finding code.corp.indeed.com/gophers/rlog v0.0.1
go: finding code.corp.indeed.com/gophers/libtest v0.0.1
go: code.corp.indeed.com/gophers/libtest@v0.0.1: unknown revision v0.0.1
go: code.corp.indeed.com/gophers/rlog@v0.0.1: unknown revision v0.0.1
go: error loading module requirements

After lots of digging and head scratching, downloaded Go, modified the source to print more verbose logging in the modfetch package, and found the root cause:

[k9 libops (master)] $ go build
go: finding code.corp.indeed.com/gophers/libtest v0.0.1
seth: stat: rev: v0.0.1
seth: gitrepo remote: https://code.corp.indeed.com/gophers/libtest.git
seth: gitrepo local: false
seth: gitrepo dir: /home/hoenig/Documents/go/pkg/mod/cache/vcs/26c2c72546174752cc7dd33aee0e9fd20922ec3bdd500d96cff072028e4d56c7
seth: gitrepo fetchLevel: 0
seth: gitrepo refs: map[]
seth: gitrepo localTags: map[]
seth: stat: didStatLocal after local hash check: false
go: finding code.corp.indeed.com/gophers/rlog v0.0.1
seth: stat: rev: v0.0.1
seth: gitrepo remote: https://code.corp.indeed.com/gophers/rlog.git
seth: gitrepo local: false
seth: gitrepo dir: /home/hoenig/Documents/go/pkg/mod/cache/vcs/8a62f5a595067cf184b8895a656492a5c7cd608500e537286869c3267fa57765
seth: gitrepo fetchLevel: 0
seth: gitrepo refs: map[]
seth: gitrepo localTags: map[]
seth: stat: didStatLocal after local hash check: false
seth: stat: loadLocalTags did not find local, r.localTags: map[]
seth: stat: now checking if name of tag or branch on remote server
seth: load-refs: entering
seth: stat: loadLocalTags did not find local, r.localTags: map[]
seth: stat: now checking if name of tag or branch on remote server
seth: load-refs: entering
seth: loadRefs: git ls-remote failed:  https://code.corp.indeed.com/gophers/rlog.git git ls-remote -q https://code.corp.indeed.com/gophers/rlog.git in /home/hoenig/Documents/go/pkg/mod/cache/vcs/8a62f5a595067cf184b8895a656492a5c7cd608500e537286869c3267fa57765: exit status 128:
	fatal: could not read Username for 'https://code.corp.indeed.com': terminal prompts disabled
seth: just did loadRefs
seth: gitrepo remote: https://code.corp.indeed.com/gophers/rlog.git
seth: gitrepo local: false
seth: gitrepo dir: /home/hoenig/Documents/go/pkg/mod/cache/vcs/8a62f5a595067cf184b8895a656492a5c7cd608500e537286869c3267fa57765
seth: gitrepo fetchLevel: 0
seth: gitrepo refs: map[]
seth: gitrepo localTags: map[]
seth: now entering big if-else tree, refs: map[]
seth: exiting stat without finding rev: v0.0.1
go: code.corp.indeed.com/gophers/rlog@v0.0.1: unknown revision v0.0.1
seth: loadRefs: git ls-remote failed:  https://code.corp.indeed.com/gophers/libtest.git git ls-remote -q https://code.corp.indeed.com/gophers/libtest.git in /home/hoenig/Documents/go/pkg/mod/cache/vcs/26c2c72546174752cc7dd33aee0e9fd20922ec3bdd500d96cff072028e4d56c7: exit status 128:
	fatal: could not read Username for 'https://code.corp.indeed.com': terminal prompts disabled
seth: just did loadRefs
seth: gitrepo remote: https://code.corp.indeed.com/gophers/libtest.git
seth: gitrepo local: false
seth: gitrepo dir: /home/hoenig/Documents/go/pkg/mod/cache/vcs/26c2c72546174752cc7dd33aee0e9fd20922ec3bdd500d96cff072028e4d56c7
seth: gitrepo fetchLevel: 0
seth: gitrepo refs: map[]
seth: gitrepo localTags: map[]
seth: now entering big if-else tree, refs: map[]
seth: exiting stat without finding rev: v0.0.1
go: code.corp.indeed.com/gophers/libtest@v0.0.1: unknown revision v0.0.1
go: error loading module requirements

Note that it is incorrect to assume the remote will support https. At least some enterprise internal git hosting infrastructures are locked down to support ssh only. This was a common complaint about the dep tool as well.

Also note this was impossible to diagnose without hacking on the Go source code. We probably shouldn't suppress that error message.

@agnivade
Copy link
Contributor

I think this was always the behavior - https://tip.golang.org/doc/faq#git_https.

Could you try the workaround suggested there and see if it works for you ?

@shoenig
Copy link
Contributor Author

shoenig commented Aug 20, 2018

The

[url "ssh://git@github.com/"]
	insteadOf = https://github.com/

workaround does work. The error message may want to point to that documentation.

@agnivade agnivade changed the title cmd/go: go mod assumes https for remote repos, suppressed errors are impossible to diagnose cmd/go: improve error message if remote repo does not support https Aug 20, 2018
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2018
@agnivade agnivade added this to the Go1.12 milestone Aug 20, 2018
@agnivade
Copy link
Contributor

/cc @bcmills @rsc

@rasky
Copy link
Member

rasky commented Aug 20, 2018

Duplicate of #26134

@rasky rasky marked this as a duplicate of #26134 Aug 20, 2018
@rasky rasky closed this as completed Aug 20, 2018
@shoenig
Copy link
Contributor Author

shoenig commented Aug 25, 2018

@rasky @bcmills @rsc Can this be re-opened? While native support for non-https repos is one thing, this generic error message is totally useless and is showing up in additional contexts, hiding critical debugging information.

For example here is a problem with Goland vs. the Go command (probably environment related, but other than "unknown revision", there's no useful information.)

modloadreqs

@ianlancetaylor
Copy link
Contributor

Reopening.

@bcmills
Copy link
Contributor

bcmills commented Nov 14, 2018

There are a bunch of interrelated issues with private repos; I'm planning to revisit that whole cluster for 1.13.

@bcmills bcmills added the GoCommand cmd/go label Nov 14, 2018
@yanyandenuonuo

This comment has been minimized.

@bcmills

This comment has been minimized.

@yanyandenuonuo
Copy link

yanyandenuonuo commented Nov 30, 2018

@bcmills it's cause go get can't use the ssh protocol, so i comment at this issue

@bcmills
Copy link
Contributor

bcmills commented Aug 8, 2019

@shoenig, we improved a lot of error messages for Go 1.13. Could you try out go1.13beta1 and let us know if the situation has improved for your configuration? (I'm guessing probably not, but it doesn't hurt to check.)

@bcmills
Copy link
Contributor

bcmills commented Aug 8, 2019

Actually, what VCS path is the server returning in the <meta> tags for https://code.corp.indeed.com/gophers/rlog?go-get=1? If the VCS only supports ssh, then the server should be returning something like:

<meta name="go-import" content="code.corp.indeed.com/gophers/rlog git ssh://code.corp.indeed.com/gophers/rlog.git">

If your server is telling the go command to use https://, then I can't really fault the go command for trying https://, and I also can't really fault it for printing whatever error message git reports when attempting to read from that URL.

(If you want better error messages from the git binary itself, probably you should raise an issue with the git maintainers...)

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 8, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

8 participants