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 <hyangah@gmail.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
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 |
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: