Skip to content

Fix: Commit and Built show unknown in the version info; go build fails on fresh checkouts#253

Open
Vikramarjuna wants to merge 1 commit intoCloud-Foundations:masterfrom
Vikramarjuna:versioning
Open

Fix: Commit and Built show unknown in the version info; go build fails on fresh checkouts#253
Vikramarjuna wants to merge 1 commit intoCloud-Foundations:masterfrom
Vikramarjuna:versioning

Conversation

@Vikramarjuna
Copy link
Copy Markdown
Contributor

@Vikramarjuna Vikramarjuna commented Apr 30, 2026

Fix: Commit and Built show unknown; go build fails on fresh checkouts

Two related issues with the embedded build info.

Problem 1 — Workspace builds lose VCS stamping

<binary> -version showed Commit: unknown, Built: unknown when the repo was built inside a Go workspace.

Sample log:
Startup: v0.13.0-8-g392198aa (commit: unknown, origin: rgooch/Dominator, behind: up to date, built: unknown, go: go1.26.2)

Cause: lib/version reads vcs.revision, vcs.time, and vcs.modified from runtime/debug.ReadBuildInfo(). Go suppresses all vcs.* settings in workspace mode, so those fields came back blank.

Fix: write commit, buildtime, and dirty into BUILD_INFO from the Makefile (using HEAD's commit time so the existing cmp -s no-op-rebuild optimization still holds). lib/version reads them from there and falls back to debug.ReadBuildInfo() only when no real BUILD_INFO is embedded.

@Vikramarjuna Vikramarjuna changed the title Versioning Fix: Commit and Built show unknown in the version info; go build fails on fresh checkouts Apr 30, 2026
Comment thread lib/version/BUILD_INFO.default Outdated
@@ -0,0 +1,7 @@
version=unknown
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find a way to do this without including a default file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the default Build info file which was introduced to support running go build without running make even once. Developers are expected to run make once, at least.

Comment thread lib/version/impl.go
revision: "unknown",
buildTime: "unknown",
}
buildInfo, ok := debug.ReadBuildInfo()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at what the compiler provides, it seems they've already done a lot of the work. Do we really need to re-invent this? Are we convinced that they haven't made good choices?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants