-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: go build
fails to read vcs info when .git is owned by a different user
#53532
Comments
This is a git issue:
|
on the safe.directory setting, git says:
|
If this was a git issue, could go build be patched to forward git error messages to the end user instead of hiding them? |
go build
Fails to Read VCS Info When in Root User go build
Fails to Read VCS Info When in Root User
go build
Fails to Read VCS Info When in Root Usergo build
Fails to Read VCS Info When in Root User
That sounds appropriate. It looks like the error probably comes from here: Perhaps we should move |
go build
Fails to Read VCS Info When in Root Usergo build
fails to read vcs info when .git is owned by a different user
Change https://go.dev/cl/468917 mentions this issue: |
This will make pkgsite pick up the latest 1.20.x. And - reenable staticcheck. - mark the working directory as safe when running for ci. (this workaround is needed after the security patch https://release.debian.org/proposed-updates/bullseye_diffs/git_2.30.2-1+deb11u1.debdiff) Updates golang/go#53532 Change-Id: I31c5fc838821d8bd6ade81dc439eb46fabb75fe1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/468917 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Jamal Carvalho <[email protected]> TryBot-Result: kokoro <[email protected]>
This affects me as well. git submodules were added like so
Content of makefile target cd gitsubmodulegolang2 && go build . added git status in here just to expose git errors like mentioned earlier comments.
I would want -buildvcs flag to accept GOENV as well so I don't have to make changes in other projects I added as submodules and modifying |
Fixes a non-deterministic build error related to `git` and directory ownership. This error has been occurring more frequently. The solution is described in a comment. This is only a Go bug in the sense that Go hides the useful portion of the error: golang/go#53532 (comment) OB-16284 Change-Id: I81894e57c4a6d3b9fe78b22fa58c0aecda8ede12
@bcmills If we do that, then what's the different between verbose and non-verbose mode?
If so, should we use runOutput instead of runOutputVerboseOnly? |
it seems that it only fails when the user building is not the same as the owner of the .git directory: golang/go#53532 I only saw it when running: ``` docker run --rm -it -v $PWD:/work --workdir /work golang go build . ``` With `docker build` it just works (maybe that command handles the users differently?). In any case, it doesn't affect CI or anything else so I'll remove it. Signed-off-by: Dimitris Karakasilis <[email protected]>
…110) * Copy over the osbuilder-tools image assets and merge with auroraboot So we can deprecate the osbuilder-tools image in favor of this one. Part of kairos-io/kairos#1633 Signed-off-by: Dimitris Karakasilis <[email protected]> * Print command output when things fail Signed-off-by: Dimitris Karakasilis <[email protected]> * Build versioned image with earthly Signed-off-by: Dimitris Karakasilis <[email protected]> * Fix ARG being in the global scope and not visible in the stage this making the `auroraboot --version` command fail https://docs.docker.com/build/building/variables/#scoping Signed-off-by: Dimitris Karakasilis <[email protected]> * Set the correct arg in pipeline Signed-off-by: Dimitris Karakasilis <[email protected]> * Add back qemu (needed by some test) Signed-off-by: Dimitris Karakasilis <[email protected]> * Remove duplicate block in dockerfile and keep luet repos up to date Signed-off-by: Dimitris Karakasilis <[email protected]> * Support images in the form of "dir:", in build-iso Signed-off-by: Dimitris Karakasilis <[email protected]> * Let elemental handle the schema and create missing tmp dir Signed-off-by: Dimitris Karakasilis <[email protected]> * Remove not necessary flag it seems that it only fails when the user building is not the same as the owner of the .git directory: golang/go#53532 I only saw it when running: ``` docker run --rm -it -v $PWD:/work --workdir /work golang go build . ``` With `docker build` it just works (maybe that command handles the users differently?). In any case, it doesn't affect CI or anything else so I'll remove it. Signed-off-by: Dimitris Karakasilis <[email protected]> --------- Signed-off-by: Dimitris Karakasilis <[email protected]>
Also discussed on the golang-nuts mailing list: https://groups.google.com/g/golang-nuts/c/LZbM2WlZoJM |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
tried to build a program with a git repository in root, program stated:
while running without root works
$ make go build -o cpgov $ sudo make install # successfully installs now that compilation is not happening
example not using Makefile as image:

What did you expect to see?
The program should not fail to grab vcs info (seemingly) just because it is in root instead of the owning user of the git repository (swapping permissions on .git to 777 did not work, swapping owner of .git to root.root did not work).
What did you see instead?
go build outputted a very unhelpful error message that it failed to obtain VCS information for some reason, and left not enough information to even properly understand the scope of this issue, for that reason I do not fully understand the scope of this issue, or even if it is somehow intended behavior.
The text was updated successfully, but these errors were encountered: