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' in a module with a higher go version may leave go.(mod|sum) in bad state #50986

Closed
myitcv opened this issue Feb 3, 2022 · 3 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. Thinking
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Feb 3, 2022

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

$ go version
go version go1.16.13 linux/arm64

Does this issue reproduce with the latest release?

The latest go1.16 version, yes.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/myitcv/gostuff/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.16.13"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4113847066=/tmp/go-build -gno-record-gcc-switches"

What did you do?

# git checkout
exec git init
exec git remote add origin https://github.com/govim/govim
exec git fetch origin 1da33d23886a18dd8280770dad0d3ae60e872e6a
exec git checkout FETCH_HEAD

# go version check
go version

# get new versions of tools and gopls
go get golang.org/x/tools/gopls@v0.0.0-20220131221016-263785d77403 golang.org/x/tools@v0.1.10-0.20220131221016-263785d77403

# try and tidy
go mod tidy

# go generate again
go generate . ./cmd/govim

The go mod tidy step fails with:

go mod tidy: go.mod file indicates go 1.17, but maximum supported version is 1.16

The go generate step fails with:

go: downloading gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
go: downloading github.com/fsnotify/fsnotify v1.4.7
govim.go:21:2: missing go.sum entry for module providing package github.com/kr/pretty (imported by github.com/govim/govim); to add:
        go get github.com/govim/govim
internal/cmd/genconfig/genconfig.go:15:2: missing go.sum entry for module providing package github.com/rogpeppe/go-internal/semver (imported by github.com/govim/govim/internal/cmd/genconfig); to add:
        go get github.com/govim/govim/internal/cmd/genconfig
govim.go:26: running "go": exit status 1
../../internal/cmd/txtarutil/main.go:39:2: missing go.sum entry for module providing package github.com/rogpeppe/go-internal/txtar (imported by github.com/govim/govim/internal/cmd/txtarutil); to add:
        go get github.com/govim/govim/internal/cmd/txtarutil
cmd/govim/main_test.go:30: running "go": exit status 1

(which is odd because the main module is github.com/govim/govim)

What did you expect to see?

It strikes me that the go get step should probably have failed in the first instance, because it couldn't make the necessary changes to go.(mod|sum) to leave both in a valid state.

What did you see instead?

go.(mod|sum) in a bad state that can't be corrected.

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Feb 3, 2022
@bcmills bcmills added this to the Backlog milestone Feb 3, 2022
@bcmills bcmills changed the title cmd/go: get leaves go.(mod|sum) in bad state cmd/go: 'go get' in a module with a higher go version may leave go.(mod|sum) in bad state Feb 3, 2022
@bcmills
Copy link
Contributor

bcmills commented Feb 3, 2022

Hmm, interesting. Yeah, it may be that go get itself should fail when the go version is higher than supported, since it doesn't in general know how to maintain invariants for higher versions.

(CC @matloob)

@thepudds
Copy link
Contributor

thepudds commented Feb 3, 2022

Is this a more specific instance of #50468?

(FWIW, I think I might have hit this too switching back and forth between Go 1.17 and tip).

@bcmills
Copy link
Contributor

bcmills commented Feb 3, 2022

Duplicate of #50468

@bcmills bcmills marked this as a duplicate of #50468 Feb 3, 2022
@bcmills bcmills closed this as completed Feb 3, 2022
@golang golang locked and limited conversation to collaborators Feb 3, 2023
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. Thinking
Projects
None yet
Development

No branches or pull requests

4 participants