-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: VCS stamping complains inappropriately about VCS in unreleated parent directory #49004
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
shouldn't this be posted in #37475 which tracks the implementation? cc @jayconrod |
This is somewhat working as intended: I reused some code from GOPATH Could you say more about your use case? Would be good to understand how common this will be. |
I agree that if the VCS containing the CWD matches the VCS containing the module root, we shouldn't fail due to other VCS directories further up. The reason they were rejected in GOPATH-mode |
My use case is that I happen to have a catch-all .bzr directory in my home. I probably shouldn't (it's a historical accident) but nonetheless I have never had any problems it ever before, and I don't think I should now. I appreciate that VCS within VCS is a specific issue when there's a VCS directory that's below the module root, but I don't think there should be a problem in this case. AFAICS the logic should be something like: find the nearest enclosing VCS directory:; if it doesn't enclose the root of the current module, it's an error; otherwise use the revision from it. I can't currently think of a reason to look outside the nearest enclosing VCS directory. |
Change https://golang.org/cl/356309 mentions this issue: |
One of my users on Gentoo is getting bitten by this because he has a fossil control directory in /var. https://bugs.gentoo.org/836261 As you can see, he is recommending that we disable the function for builds within our package manager. What do you suggest? |
Thanks @williamh ! I'm that gentoo user. I have to say that, during each build, firing up software that will ascend the whole directory tree looking for control directories that may or may not be project related is probably not a good idea. Not everybody compiles using pristine machine images... Chances are that version information of that unrelated project may be used. And many people will have several VCS installed, meaning that the search will happen using git, hg, bzr, fossil and whatnot, increasing the attack or failure surface a lot. I do see that sometimes a go project can be in a subdirectory of a larger projects' root. One way to avoid the problem would be to explicitly specify the VCS root in the build. Or to place a "stop VCS search here" file or directory in the project's root. Or, at least to never fire up the VCS search if a version tag is given explicitly (as in gentoo I believe it is). One specific problem with fossil might also be that it opens the repository read/write even with only informational commands. Not sure that all the other systems open theirs readonly in this case. Sandbox systems would probably abort the build in this case as well, as the repository directory will often be out of bounds. So, without one of the provisions mentioned above avoiding the directory ascending altogether, each and every VCS would need a sandbox-safe "probe mode". This probably means asking too much and we're back to adding more logic to safely conclude that 1) we need info from the VCS and 2) we're actually inside a relevant project-specific checkout. What can be done immediately is, of course, to set -buildvcs=false if we know that we're not building from a checkout but some tar release. Are there any objections to that? |
There is going to be a new default of |
That means all package manager builds in Gentoo will end up having -buildvcs=false since we build from tarballs. |
@williamh unfortunately Go 1.17 will try to consume |
Unfortunately I just discovered this. |
If you can in any way control the environment where |
Another potential idea: set up |
A wrapper might be an option, but it would need to be a wrapper that only the package manager can use. I don't really want to change the behavior of the go command outside the package manager context. |
… builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - #2508 (comment) , - ko-build/ko#672 - golang/go#49004
… builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - #2508 (comment) , - ko-build/ko#672 - golang/go#49004
* deployment/docker: pass `-buildvs=false` to `go build` for production builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - #2508 (comment) , - ko-build/ko#672 - golang/go#49004 * lib/netutil: limit the number of concurrently established connections when calling ConnPool.Get() This should reduce potential spikes in the number of established connections in the following cases: - when the connection establishing procedure becomes temporarily slow - after a temporary spike in the rate of ConnPool.Get() calls See #2552 * docs/CHANGELOG.md: document c8af625 See #1322 (comment) * docs/Cluster-VictoriaMetrics.md: typo fix: `by by` -> `by` * docs: add `resource usage limits` docs, which describe fine-grained tuning for various resource usage limits * docs/Cluster-VictoriaMetrics.md: the `/api/v1/label/.../values` query can take CPU and ram at both vmstorage and vmselect * Update root Readme and root vmagent readme Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
* deployment/docker: pass `-buildvs=false` to `go build` for production builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - #2508 (comment) , - ko-build/ko#672 - golang/go#49004 * lib/netutil: limit the number of concurrently established connections when calling ConnPool.Get() This should reduce potential spikes in the number of established connections in the following cases: - when the connection establishing procedure becomes temporarily slow - after a temporary spike in the rate of ConnPool.Get() calls See #2552 * docs/CHANGELOG.md: document c8af625 See #1322 (comment) * docs/Cluster-VictoriaMetrics.md: typo fix: `by by` -> `by` * docs: add `resource usage limits` docs, which describe fine-grained tuning for various resource usage limits * docs/Cluster-VictoriaMetrics.md: the `/api/v1/label/.../values` query can take CPU and ram at both vmstorage and vmselect * Update root Readme and root vmagent readme Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
… builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - VictoriaMetrics#2508 (comment) , - ko-build/ko#672 - golang/go#49004
* deployment/docker: pass `-buildvs=false` to `go build` for production builds This should resolve the `error obtaining VCS status: exit status 128` error when the environment contains incorrect version of git or has incorrect access rights to the directory with VictoriaMetrics source code. See the following links for additional info: - VictoriaMetrics#2508 (comment) , - ko-build/ko#672 - golang/go#49004 * lib/netutil: limit the number of concurrently established connections when calling ConnPool.Get() This should reduce potential spikes in the number of established connections in the following cases: - when the connection establishing procedure becomes temporarily slow - after a temporary spike in the rate of ConnPool.Get() calls See VictoriaMetrics#2552 * docs/CHANGELOG.md: document c8af625 See VictoriaMetrics#1322 (comment) * docs/Cluster-VictoriaMetrics.md: typo fix: `by by` -> `by` * docs: add `resource usage limits` docs, which describe fine-grained tuning for various resource usage limits * docs/Cluster-VictoriaMetrics.md: the `/api/v1/label/.../values` query can take CPU and ram at both vmstorage and vmselect * Update root Readme and root vmagent readme Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Sorry, this is where google leads with the error and this thread is a bit cluttered... So, the solution is to just use |
This particular bug was about nested VCS repositories causing an error - that was solved, and no workaround is needed. I assume the problem you have is that git may not be installed inside your Docker image, where you run |
Thanks for your answer!
But |
Please file a new bug with steps to reproduce. |
Did it with sample nested repo: #53640 (repo: https://github.com/MichaelVoelkel/vcs-test ) |
How to replicate the error: `make docker` Previous error: ``` ... long log ---> f394d136bb6c Step 7/24 : ADD proto/go.sum proto/go.sum ---> 7fca7e520cb3 Step 8/24 : ENV CGO_ENABLED 1 ---> Running in ca87bf346155 Removing intermediate container ca87bf346155 ---> af2dbef0c762 Step 9/24 : RUN go mod download ---> Running in 98785997fa9c Removing intermediate container 98785997fa9c ---> f74577fb6d14 Step 10/24 : ADD . . ---> f1cc0ac767f0 Step 11/24 : RUN go build -tags sqlite -o /usr/bin/keto . ---> Running in 913258959d81 error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. The command '/bin/sh -c go build -tags sqlite -o /usr/bin/keto .' returned a non-zero code: 1 ``` This is fixed by setting -buildvcs=false ref: golang/go#49004
How to replicate the error: `make docker` Previous error: ``` ... long log ---> f394d136bb6c Step 7/24 : ADD proto/go.sum proto/go.sum ---> 7fca7e520cb3 Step 8/24 : ENV CGO_ENABLED 1 ---> Running in ca87bf346155 Removing intermediate container ca87bf346155 ---> af2dbef0c762 Step 9/24 : RUN go mod download ---> Running in 98785997fa9c Removing intermediate container 98785997fa9c ---> f74577fb6d14 Step 10/24 : ADD . . ---> f1cc0ac767f0 Step 11/24 : RUN go build -tags sqlite -o /usr/bin/keto . ---> Running in 913258959d81 error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. The command '/bin/sh -c go build -tags sqlite -o /usr/bin/keto .' returned a non-zero code: 1 ``` This is fixed by setting -buildvcs=false ref: golang/go#49004
Just ran into this on GitHub Actions + Fly.io no idea what vcs is or why it only happened in that specific environment (fly.io manual deploy works fine, GitHub Actions can also build Docker images fine, but if I invoked So, just commenting here with some keywords to help others who may be searching for that exact combination of tools - because I couldn't find anything! Also gonna ping @michaeldwan just in case this is something the Fly team can fix in their environment for Go applications :) |
commit 1cbec68
The Go compiler refuses to build my usual executables without specifying the
-buildvcs=false
flag.Here's a
testscript
reproducer:This fails as follows:
When the nearest VCS directory is at the root of the current module, I believe it should be taken as definitive and the search should go no further back into parent directories.
The text was updated successfully, but these errors were encountered: