Skip to content

cmd/go: version stamping from VCS no longer works in Go 1.25 when in a nested module and repo root has no go.mod file #74763

@dmitshur

Description

@dmitshur

Go version

go version go1.25rc2 darwin/arm64

Output of go env in your module/workspace:

(not relevant)

What did you do?

I noticed a regression in a particular edge case of the -buildvcs behavior.

Consider the following minimal sequence that reproduces it:

$ cd $(mktemp -d)
$ mkdir subdir
$ (cd subdir && go mod init example.com/subdir && go get [email protected])
$ echo 'package main; import ("fmt"; "log"; "runtime/debug"); func main() { bi, ok := debug.ReadBuildInfo(); if !ok { log.Fatalln("no build info") }; fmt.Println(bi.Main.Version) }' > subdir/main.go
$ git init && git add . && git commit -m 'example commit'
$ cd subdir
$ GOTOOLCHAIN=go1.24.5 go run -buildvcs=true .
v0.0.0-20250726003140-f31775ad565e
$ GOTOOLCHAIN=go1.25rc2 go run -buildvcs=true .
(devel)

What did you see happen?

As visible above, when using Go 1.25 the reported main module version is "(devel)" despite -buildvcs=true and the example.com/subdir module being inside a git repository.

What did you expect to see?

As visible above, when using Go 1.24 the reported main module version is "v0.0.0-20250726003140-f31775ad565e". I expected Go 1.25 to report the same version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions