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: go1 branch breaks go get -u when default branch is still master #27526

Closed
stanford-scs opened this issue Sep 6, 2018 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@stanford-scs
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

Probably. 1.10.3 is very recent.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build171873923=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  • Create a remote repository for a simple program in which the go1 branch is one commit ahead of master, but HEAD still points to master.

  • Install the program with go get -u github.com/whatever. This works.

  • Now without changing the repository, try go get -u github.com/whatever again, and it will fail.

What did you expect to see?

Within the gopath, go has cloned the repository and created a local branch tracking origin/go1. go get -u pulls from go1 (with nothing to pull since no changes) and successfully rebuilds the program.

What did you see instead?

$ go get -u github.com/whatever
# cd /home/user/go/src/github.com/whatever; git pull --ff-only
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

package github.com/whatever: exit status 1

And if I cd to /home/user/go/src/github.com/whatever, I'm in a detached head state:

$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref
@agnivade
Copy link
Contributor

agnivade commented Sep 6, 2018

Could you try and see the behavior with 1.11 ?

@bcmills bcmills changed the title go1 branch breaks go get -u when default branch is still master cmd/go: go1 branch breaks go get -u when default branch is still master Sep 6, 2018
@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 6, 2018
@stanford-scs
Copy link
Author

stanford-scs commented Sep 6, 2018

I can confirm that the problem also happens with go 1.11. For an easy repro, try installing my goxdr tool twice:

go get -u github.com/xdrpp/stc/goxdr
go get -u github.com/xdrpp/stc/goxdr

@agnivade agnivade removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 6, 2018
@agnivade agnivade added this to the Go1.12 milestone Sep 6, 2018
@rsc
Copy link
Contributor

rsc commented Oct 24, 2018

From go help get:

When checking out or updating a package, get looks for a branch or tag
that matches the locally installed version of Go. The most important
rule is that if the local installation is running version "go1", get
searches for a branch or tag named "go1". If no such version exists
it retrieves the default branch of the package.

Yes, it's weird, but it's always been that way, and we're not going to change that behavior today. Instead, we're going to delete this whole thing once modules are ready (in a couple releases). For now, sorry, but don't name a branch go1 if you don't want go get to use it (even for -u).

@rsc rsc closed this as completed Oct 24, 2018
@stanford-scs
Copy link
Author

@rsc I think maybe you misunderstood the bug report. I want go get to use the branch, but instead it's using a detatched head. Sounds like you don't care, though, but I thought I'd at least set the record straight that the actual behavior is not what you think it is or what the docs describe.

@golang golang locked and limited conversation to collaborators Oct 25, 2019
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

5 participants