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

Version set via ldflags is ignored when building from source tarball #1709

Closed
stefanb opened this issue Jul 3, 2024 · 0 comments · Fixed by #1711
Closed

Version set via ldflags is ignored when building from source tarball #1709

stefanb opened this issue Jul 3, 2024 · 0 comments · Fixed by #1711
Labels
type: bug Something not working as intended.

Comments

@stefanb
Copy link

stefanb commented Jul 3, 2024

  • Task version: 3.38.0
  • Operating system: All
  • Experiments enabled: likely irrelevant

In

It was noted, that the --version test failed with Expected /Task\ version:\ 3\.38\.0/ to match "Task version: (devel) ()\n

Meaning that the test was expecting Task version: 3.38.0 but task --version returned Task version: (devel) ()\n

Even if the correct version was passed to the compiler in ldflags.

Bug introduced with

Where it was assumed that the version would be empty by default:

func init() {
info, ok := debug.ReadBuildInfo()
if !ok || info.Main.Version == "" {
version = "unknown"
} else {
version = info.Main.Version
sum = info.Main.Sum
}
}

Where in fact Version defaults "(devel)" if Go compiler cannot read git info during build, which is the case when building from the downloaded source tarball.
You can try that in playground, where there is also no git info present: https://go.dev/play/p/MCLXd4QaUru

Because of this the version set via Go ldflags is always overrwritten and never used/returned by GetVersion*() functions.

This is the reason for

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jul 3, 2024
@vmaerten vmaerten added type: bug Something not working as intended. and removed state: needs triage Waiting to be triaged by a maintainer. labels Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants