Navigation Menu

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: 'go get' fails to track a branch which contains a / #38861

Closed
grellyd opened this issue May 4, 2020 · 9 comments
Closed

cmd/go: 'go get' fails to track a branch which contains a / #38861

grellyd opened this issue May 4, 2020 · 9 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@grellyd
Copy link

grellyd commented May 4, 2020

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

$ go version

go version go1.14.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/grellyd/Library/Caches/go-build"
GOENV="/Users/grellyd/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="go.company.io"
GONOSUMDB="go.company.io"
GOOS="darwin"
GOPATH="/Users/grellyd/wrk/go"
GOPRIVATE="go.company.io"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/grellyd/wrk/go/src/go.company.io/repo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/34/mxhn7dp54z9fp1phcl1t0mr80000gn/T/go-build088434320=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was attempting to test changes in a branch of a vendored dependency on a private repository. Having never done this before using go modules, I found the docs (https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) which indicated I should go get the associated repo and have the default version overridden by adding an @version suffix to the package argument, as in 'go get golang.org/x/text@v0.3.0'.

I assumed from there that I should add the branch as the checkout point. This resulted in the error below, indicating the version string was disallowed. Our company namespaces our github branches before doing the proper branch name. For us, slashes in the branch name are a common workflow. We occasionally also use multiple sub-namespaces for organisation.

Upon further research, I found a docs issue (#30851), and an associated issue (#36902). After commenting on the final issue, I opened this one.

A workaround at this time is to git log the sha of the HEAD of the namespaced branch and then go get using that sha. EG: go get github.com/org/repo@sha

An ideal configuration would download new commits upon a subsequent go get, which the sha checkout would not.

What did you expect to see?

go get github.com/org/repo@namespace/branch downloading and checking out that go module at that branch sha.

What did you see instead?

go get github.com/org/repo@namespace/branch: github.com/org/repo@namespace/branch: invalid version: version "branch" invalid: disallowed version string

@jayconrod jayconrod added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 5, 2020
@jayconrod jayconrod added this to the Backlog milestone May 5, 2020
@thomaspeugeot
Copy link

notice that vscode default branch naming policy is with a slash, therefore, the issue is systematic with this configuration.

https://github.com/microsoft/vscode-pull-request-github/blob/main/package.json

		"githubIssues.issueBranchTitle": {
        			"type": "string",
        			"default": "${user}/issue${issueNumber}",
        		},

@andig
Copy link
Contributor

andig commented Feb 20, 2022

I‘ve tried quoting the branch name, but that doesn‘t help either.

@norru

This comment was marked as duplicate.

@tonglil
Copy link

tonglil commented Jul 15, 2022

See #32955

@mvdan
Copy link
Member

mvdan commented Jul 15, 2022

Thank you @tonglil - this is indeed a duplicate of the older issue, which has had more discussion. My guess is that this issue got more thumbs up reactions because the title is closer to what the user's situation tends to be: git branches containing slashes.

I'm going to close this as a duplicate for now. For updates, please subscribe to #32955.

As a temporary workaround in case any of you are blocked, you can use GOPROXY=direct go get in the meantime. The bug is in the proxy.golang.org software, not in cmd/go itself.

@mvdan mvdan closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2022
@directionless
Copy link

Is it a dup? #32955 is focused on proxy behaviors. I'd swear I encountered this before the proxy

@mvdan
Copy link
Member

mvdan commented Jul 15, 2022

I am pretty sure, and just ran a test:

$ go get mvdan.cc/garble@test/with/slashes
go: mvdan.cc/garble@test/with/slashes: invalid version: version "test/with/slashes" invalid: disallowed version string
$ GOPROXY=direct go get mvdan.cc/garble@test/with/slashes
go: downloading mvdan.cc/garble v0.7.1-0.20220711113617-8bc971e0a284

@grellyd
Copy link
Author

grellyd commented Jul 26, 2022

Thanks for the link to the underlying issue @mvdan. For what it is worth, I never set GOPROXY myself: it remained the default value of GOPROXY="https://proxy.golang.org,direct".

Am I correct in understanding the workaround for this issue is to remove the Golang proxy from GOPROXY and instead only prefer direct? In other words, set GOPROXY=direct in our environment.

@mvdan
Copy link
Member

mvdan commented Jul 27, 2022

Correct. Just don't set GOPROXY=direct permanently or globally, because that would greatly slow down Go modules in general.

@golang golang locked and limited conversation to collaborators Jul 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules 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

9 participants