-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: add (and default to) -buildvcs=auto
#51748
Comments
setting |
this is correct, my directory contains a |
I don't think this is a duplicate; my issue is about This is about |
I think the current I’ve added Ideally, |
I think they key word there is "otherwise" :) The source trees aren't identical. I don't have strong feelings on what the default for If you want your Go builds to be fully reproducible regardless of details like the presence of VCS or the current directory, you already have to supply flags like |
I will add one reason why the default being The other case is reproducible builds, like you say, where the presence or state of the VCS can cause problems. My argument in the previous comment is that doing a fully reproducible Go build requires a bit of knowledge and care, so the average person doing that will already know what flags to supply and how to stay up to date with changes to flags or default behavior in |
Explicitly disable buildvcs for build and test on FreeBSD. See golang/go#51723 and golang/go#51748.
I don't much care whether vcs info is included in builds by default, but there was a breaking change in that my |
@ocket8888 that would make |
In this case it default to |
@DasSkelett then see #51748 (comment). I again don't have a strong opinion here, but this is not a matter of simply changing the default behavior. |
Well, it now produces either an entire binary or nothing at all based on whether a program is installed locally, which is worse IMO. RE: #51748 (comment),
In this situation the user has already demonstrated at least basic knowledge of what is basically the world standard in version control systems. By contrast I had no idea Go put vcs info in its binaries until my builds started failing. I don't even know how to extract that information from a Go binary - but I do know how to
To be clear, this wasn't simply a change in default behavior, it was - at the very least from the perspective of $ go help build | grep vcs | wc -l
0
$ go version
go version go1.17.8 linux/amd64
It is minimal, but it's still a nuisance. Backward compatibility for |
Explicitly disable buildvcs for build and test on FreeBSD. See golang/go#51723 and golang/go#51748.
It's new, so not knowing it would be embedded is normal, but the build fails with very clear instructions.
An executable isn't always used on the system or by the person who built it, and nothing guarantees the binary you kept around is at the same version as your source tree if you're actively working on something. I think the default should remain as is, on a minimal system there are already other things you have to disable (eg set |
I guess it depends on what you prioritize, but I think I fully empathize with some And, to reiterate, there are three options which I hope are reasonable:
|
Well like I said I don't care about the default behavior one way or the other, since existing build systems that don't utilize it would be none the wiser. I just don't think a failure to find
It shouldn't do that silently, I would definitely expect to see a warning on stderr when some feature fails to work.
This isn't a huge deal. It's a little annoying, but the fix will take me all of one second to implement. I do find the statement "soft breakages ... are sometimes necessary to get new features" a bit ironic for a team/tool/ecosystem that are of the opinion "there is no good way to way to make breaking changes to a library or a tool", "Breaking changes are bad", etc. :P . But no, this isn't a hill I'm ready to die on (and trust me there are more than enough of those already), those are pretty simple fixes/workarounds. I do still think a warning is a better UX than a failure here, but not strongly enough to continue arguing in its favor. |
I wouldn't like that, and it most likely won't happen, the stance on compiler warnings in the Go team appears to be:
https://go.dev/doc/faq#unused_variables_and_imports A warning here isn't useful and just adds noise. The only way to fix the warning is to disable the feature, so you might as well fail the build and require the same (which is, in the end, just a one time change in the CI scripts). Warnings tend to be ignored if they are even noticed at all (nobody looks at the CI logs if everything's green, and this problem is unlikely to occur on developer machines). |
if the folder for my point of view I would expect it skips vcs and compiles because vcs is not forced to be present. But i am also okay with the breaking change, we had a few in the last years using |
I see three possible options here:
Personally I'm kind of leaning toward (3). |
I would find (3) acceptable, for whatever that's worth. |
I oppose 2, in terms of easier reproducibility. I prefer 1 over 3 in terms of less "auto" magic, but it's not a strong conviction; either would still solve my problem, since the average user running |
Backport issue(s) opened: #51798 (for 1.18). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
I think there may be a further complication. By relying on This could happen, for instance, if there is a I can imagine |
There are likely numerous obscure ways buildvcs/git could fail on existing repos, or fail in future. It might be better for Effectively it a choice between:
I think the later is a better choice. It would have prevented several of the breakages seen during the development of buildvcs. |
@mpx, you are correct that it would have prevented several of the failure modes that we saw (and you fixed — thanks again!) during development, but on the other hand we would not have seen those failure modes and known to fix them, which I think would have left us in a worse state overall — we would have been left with more situations in which the VCS metadata is unexpectedly, silently, and (in some sense) inexplicably missing from the resulting binary. I think |
Personally, if |
- letting the pipeline do the actual golang bump and tests - go tries to include git information but stemcells do not include git binary golang/go#51748 Signed-off-by: Andrew Crump <crumpan@vmware.com>
- letting the pipeline do the actual golang bump and tests - go tries to include git information but stemcells do not include git binary golang/go#51748 - go install instead of go get for installing in go 1.18 Signed-off-by: Ben Fuller <benjaminf@vmware.com> Co-authored-by: Ben Fuller <benjaminf@vmware.com>
Change https://go.dev/cl/398855 mentions this issue: |
* fix for go 1.18 - letting the pipeline do the actual golang bump and tests - go tries to include git information but stemcells do not include git binary golang/go#51748 - go install instead of go get for installing in go 1.18 Signed-off-by: Ben Fuller <benjaminf@vmware.com> Co-authored-by: Ben Fuller <benjaminf@vmware.com> * increasing the timeouts seems to help? Co-authored-by: Andrew Crump <crumpan@vmware.com>
Change https://go.dev/cl/400454 mentions this issue: |
If the .git directory is included, the build fails on a new golang feature that naively assumes a build environment with a .git folder has git installed.
…s the default When we added VCS stamping in the Go 1.18 release, we defaulted to -buildvcs=true, on the theory that most folks will actually want VCS information stamped. We also made -buildvcs=true error out if a VCS directory is found and no VCS tool is available, on the theory that a user who builds with '-buildvcs=true' will be very surprised if the VCS metadata is silently missing. However, that causes a problem for CI environments that don't have the appropriate VCS tool installed. (And we know that's a common situation because we're in that situation ourselves — see #46693!) The new '-buildvcs=auto' setting provides a middle ground: it stamps VCS information by default when the tool is present (and reports explicit errors if the tool errors out), but omits the metadata when the tool isn't present at all. Updates #51748. Updates #51999. Fixes #51798. Change-Id: Iebc955c2af0abca9b7517f62ca48b1d944eb2df4 Reviewed-on: https://go-review.googlesource.com/c/go/+/398855 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 4569fe6) Reviewed-on: https://go-review.googlesource.com/c/go/+/400454 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
I build my projects with a basic Dockerfile based on
golang:alpine
, the project dependencies are in the /vendor directory, so no additional download is required. (e.g. when the build containers are not connected to the internet)it also uses the flag:
ENV GOFLAGS -mod=vendor
this worked well before 1.18 (with an older version of golang:alpine):
after i did
docker pull golang:alpine
it now fails because it tries to download the dependencies with git (which is also not installed in the alpine image):doing a
go mod vendor
does not change anything, any advice?The text was updated successfully, but these errors were encountered: