Skip to content

cmd/go: local version stamping doesn't work with v2+ #72877

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

Closed
MrBoombastic opened this issue Mar 15, 2025 · 6 comments
Closed

cmd/go: local version stamping doesn't work with v2+ #72877

MrBoombastic opened this issue Mar 15, 2025 · 6 comments
Assignees
Labels
BugReport Issues describing a possible bug in the Go implementation. FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go
Milestone

Comments

@MrBoombastic
Copy link

Go version

go version go1.24.1 windows/amd64

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=on
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\user\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\user\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\user\AppData\Local\Temp\go-build3582125240=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\Users\user\Desktop\path\TestDevel\go.mod
set GOMODCACHE=C:\Users\user\go\pkg\mod
set GONOPROXY=github.com
set GONOSUMDB=github.com
set GOOS=windows
set GOPATH=C:\Users\user\go
set GOPRIVATE=github.com
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:/Users/user/go/go1.24.1
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\user\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\user\go\go1.24.1\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.1
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

ReadBuildInfo.Main.Version shows "(devel)" after tagging v2 package as v2.

package main

import (
	"fmt"
	"runtime/debug"
)

func main() {
	info, _ := debug.ReadBuildInfo()
	fmt.Println(info.Main)
}

Although my personal case may be different - I'm not 100% sure how I broke this feature in my private repo - the scenario below successfully reproduces the same output, so I think it's still worth reporting.

Thanks to user truck.dad from the Discord Gophers server for his initial support and the Unix PoC!

What did you see happen?

@echo off

git init
go mod edit -module test.module
git add . && git commit -m "test"
git tag v1.2.3
go build .
test.module.exe

del test.module.exe
go mod edit -module test.module/v2
git add . && git commit -m "test"
git tag v2.3.4
go build .
test.module.exe
Initialized empty Git repository in C:/Users/usr/path/TestDevel/.git/
warning: in the working copy of 'go.mod', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'main.go', LF will be replaced by CRLF the next time Git touches it
[master (root-commit) 950c98b] test
 7 files changed, 57 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 TestDevel.iml
 create mode 100644 go.mod
 create mode 100644 main.go
 create mode 100644 test.bat
 create mode 100644 test.module.exe
 create mode 100644 test.sh

{test.module v1.2.3  <nil>}

warning: in the working copy of 'go.mod', LF will be replaced by CRLF the next time Git touches it
[master 64f3139] test
 2 files changed, 1 insertion(+), 1 deletion(-)
 delete mode 100644 test.module.exe

{test.module/v2 (devel)  <nil>}

What did you expect to see?

{test.module v1.2.3  <nil>}

{test.module/v2 v2.3.4  <nil>}

or pseudoversion, or literally anything other than "(devel)"

@MrBoombastic MrBoombastic changed the title runtime/debug: BuildInfo.Main.Version equals "(devel)" after git tag manipulation runtime/debug: BuildInfo.Main.Version equals "(devel)" instead of expected tag for v2 Mar 15, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 15, 2025
@dr2chase
Copy link
Contributor

@golang/compiler @matloob

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 15, 2025
@seankhliao seankhliao changed the title runtime/debug: BuildInfo.Main.Version equals "(devel)" instead of expected tag for v2 cmd/go: local version stamping doesn't work with v2+ Mar 15, 2025
@seankhliao seankhliao added the GoCommand cmd/go label Mar 15, 2025
@rfjakob
Copy link

rfjakob commented Mar 20, 2025

gocryptfs author here. Same thing on Linux @samthanawalla :

~/code/gocryptfs$ git describe
v2.5.2

~/code/gocryptfs$ go build

~/code/gocryptfs$ go version -m gocryptfs | head
gocryptfs: go1.24.1
	path	github.com/rfjakob/gocryptfs/v2
	mod	github.com/rfjakob/gocryptfs/v2	(devel)	

@bdunlap-synack
Copy link

bdunlap-synack commented Mar 22, 2025

i'm seeing the old (devel) behavior even on non 2+ using the 1.24 toolchain / mod version (version of code was 1.2.4). I expected to see the new marked +dirty behavior at worst as documented in the release notes instead. (the repo was clean so it should just work.)

@ldemailly
Copy link

@bdunlap-synack details ? repro how?

@samthanawalla samthanawalla self-assigned this Mar 31, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/661875 mentions this issue: cmd/go: fix version stamping for v2 modules

@dmitshur dmitshur added FixPending Issues that have a fix which has not yet been reviewed or submitted. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 2, 2025
@dmitshur dmitshur added this to the Go1.25 milestone Apr 2, 2025
@samthanawalla samthanawalla added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go
Projects
None yet
Development

No branches or pull requests

10 participants