golang/go

cmd/go: `go build` fails to read vcs info when .git is owned by a different user

Open

#53,532 opened on Jun 24, 2022

View on GitHub
 (8 comments) (1 reaction) (0 assignees)Go (19,008 forks)batch import
BadErrorMessageGoCommandNeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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)?

What did you do?

tried to build a program with a git repository in root, program stated:

$ sudo make
go build -o cpgov
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
make: *** [Makefile:5: cpgov] Error 1

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: Terminal screen with contents "$ sudo go build -o cpgov;
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
$ go build -o cpgov;
$ ls cpgov;
cpgov
"

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.

Contributor guide