Skip to content
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/dist: fails with buildvcs=false errors if invalid .git exists in parent of GOROOT_BOOTSTRAP #61620

Open
paralin opened this issue Jul 27, 2023 · 6 comments · May be fixed by #61621
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@paralin
Copy link
Contributor

paralin commented Jul 27, 2023

Related: #54852 - cc @williamh @bcmills

In Buildroot we have a build failure when there exists an invalid .git in a parent directory of GOROOT_BOOTSTRAP: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525

Building Go toolchain1 using /builds/buildroot.org/buildroot/test-output/TestMender/host/lib/go-1.19.10.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
go tool dist: FAILED: /builds/buildroot.org/buildroot/test-output/TestMender/host/lib/go-1.19.10/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...: exit status 1

Reproduction of the issue:

# This reproduction sets up a directory structure that breaks Go make.bash.
# make.bash should not break due to .git files outside of the Go sources.
#
# The error specifically occurs when an invalid .git is present in a parent git
# directory of the GOROOT_BOOTSTRAP. Go issue #61620
mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash
# Build fails using -buildvcs=false errors.

The error only occurs when the .git that git detects in the parent directory
of the GOROOT_BOOTSTRAP is invalid or not present causing errors when running git commands within GOROOT_BOOTSTRAP.

paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
When compiling without a Git repository, "go install" returns an error:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Set -buildvcs=false in go install when isGitDir() returns false.

Fixes: golang#61620
Related: golang#54852

Signed-off-by: Christian Stewart <christian@aperture.us>
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
Add an environment variable to bypass the isGitRepo() check and force it to
return false, thereby also setting -buildvcs=false during "go install."

This is useful in situations where the .git directory may be present but we
still want to force cmd/dist to ignore it.

Fixes: golang#61620
Related: golang#54852

Signed-off-by: Christian Stewart <christian@aperture.us>
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
When compiling without a Git repository, "go install" returns an error:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Set -buildvcs=false in go install when isGitDir() returns false.

Fixes: golang#61620
Related: golang#54852
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
Add an environment variable to bypass the isGitRepo() check and force it to
return false, thereby also setting -buildvcs=false during "go install."

This is useful in situations where the .git directory may be present but we
still want to force cmd/dist to ignore it.

Fixes: golang#61620
Related: golang#54852
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
When compiling without a Git repository, "go install" returns an error:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Set -buildvcs=false in go install when isGitDir() returns false.

Fixes: golang#61620
Related: golang#54852
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
Add an environment variable to bypass the isGitRepo() check and force it to
return false, thereby also setting -buildvcs=false during "go install."

This is useful in situations where the .git directory may be present but we
still want to force cmd/dist to ignore it.

Fixes: golang#61620
Related: golang#54852
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
When compiling without a Git repository, "go install" returns an error:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Set -buildvcs=false in go install when isGitDir() returns false.

Fixes: golang#61620
Related: golang#54852
paralin added a commit to paralin/go that referenced this issue Jul 27, 2023
Add an environment variable to bypass the isGitRepo() check and force it to
return false, thereby also setting -buildvcs=false during "go install."

This is useful in situations where the .git directory may be present but we
still want to force cmd/dist to ignore it.

Fixes: golang#61620
Related: golang#54852
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/513835 mentions this issue: cmd/dist: set buildvcs=false if not within a git repository

@dmitshur
Copy link
Contributor

What is a sequence of steps that reproduces this issue in the Go project?

The following sequence does not produce an error:

$ cd $(mktemp -d)
tmp.tQscHcxE $ git clone https://go.googlesource.com/go
Cloning into 'go'...
[...]
tmp.tQscHcxE $ cd go
go $ rm -rf .git
go $ git status
fatal: not a git repository (or any of the parent directories): .git
go $ cd src
src $ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.21rc3 darwin/arm64)
go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT
src $ echo go1.22-issue61620 > ../VERSION 
src $ ./make.bash                        
Building Go cmd/dist using /usr/local/go. (go1.21rc3 darwin/arm64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /tmp/tmp.tQscHcxE/go
Installed commands in /tmp/tmp.tQscHcxE/go/bin
*** You need to add /tmp/tmp.tQscHcxE/go/bin to your PATH.
src $ echo $?
0
src $ export PATH="/tmp/tmp.tQscHcxE/go/bin:$PATH"
src $ go version
go version go1.22-issue61620 darwin/arm64

@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 28, 2023
@paralin
Copy link
Contributor Author

paralin commented Jul 28, 2023

@dmitshur Reproduction of the issue:

# This reproduction sets up a directory structure that breaks Go make.bash.
# make.bash should not break due to .git files outside of the Go sources.
#
# The error specifically occurs when an invalid .git is present in a parent git
# directory of the GOROOT_BOOTSTRAP. Go issue #61620
mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash
# Build fails using -buildvcs=false errors.

It is in itself a problem that the presence of .git directories in the parent
folders above the Go sources have any influence on the behavior of make.bash.

The error only occurs when the .git that git detects in the parent directory of the GOROOT_BOOTSTRAP is invalid or not present causing errors when running git commands within GOROOT_BOOTSTRAP.

paralin added a commit to paralin/go that referenced this issue Jul 28, 2023
When building go-bootstrap as part of the make.bash process, the cmd/dist
invokes the bootstrap Go compiler to build the go_bootstrap tool:

${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...

If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP},
make.bash will fail. Reproduction of the issue:

  mkdir go-issue-61620
  cd ./go-issue-61620
  wget https://go.dev/dl/go1.19.11.src.tar.gz
  mkdir go-bootstrap
  tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
  cd ./go-bootstrap/src/
  bash make.bash
  cd ../../
  wget https://go.dev/dl/go1.20.6.src.tar.gz
  mkdir go
  tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
  printf "gitdir: ../../does/not/exist/.git" > ./.git
  cd ./go/src/
  GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The build fails with the following error:

  Building Go toolchain1 using [snip]/go-1.19.10.
  error obtaining VCS status: exit status 128
    Use -buildvcs=false to disable VCS stamping.
  go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go \
    compiler_bootstrap purego bootstrap/cmd/...: exit status 1

This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We
don't need the revision information in those binaries anyway. Setting this flag
was previously not done as we were unsure if the go-bootstrap compiler would be
new enough to support the buildvcs build flag. However, since Go 1.20.x, Go
1.19.x is the minimum version for go-bootstrap, and supports -buildvcs=false. We
can now set -buildvcs=false without worrying about compatibility.

Related: golang#54852
Fixes: golang#61620
paralin added a commit to paralin/go that referenced this issue Jul 28, 2023
When building go-bootstrap as part of the make.bash process, the cmd/dist
invokes the bootstrap Go compiler to build the go_bootstrap tool:

${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...

If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP},
make.bash will fail. Reproduction of the issue:

  mkdir go-issue-61620
  cd ./go-issue-61620
  wget https://go.dev/dl/go1.19.11.src.tar.gz
  mkdir go-bootstrap
  tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
  cd ./go-bootstrap/src/
  bash make.bash
  cd ../../
  wget https://go.dev/dl/go1.20.6.src.tar.gz
  mkdir go
  tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
  printf "gitdir: ../../does/not/exist/.git" > ./.git
  cd ./go/src/
  GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The build fails with the following error:

  Building Go toolchain1 using [snip]/go-1.19.10.
  error obtaining VCS status: exit status 128
    Use -buildvcs=false to disable VCS stamping.
  go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go \
    compiler_bootstrap purego bootstrap/cmd/...: exit status 1

This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We
don't need the revision information in those binaries anyway. Setting this flag
was previously not done as we were unsure if the go-bootstrap compiler would be
new enough to support the buildvcs build flag. However, since Go 1.20.x, Go
1.19.x is the minimum version for go-bootstrap, and supports -buildvcs=false. We
can now set -buildvcs=false without worrying about compatibility.

Related: golang#54852
Fixes: golang#61620
paralin added a commit to paralin/go that referenced this issue Jul 28, 2023
When building go-bootstrap as part of the make.bash process, the cmd/dist
invokes the bootstrap Go compiler to build the go_bootstrap tool:

${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...

If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP},
make.bash will fail. Reproduction of the issue:

  mkdir go-issue-61620
  cd ./go-issue-61620
  wget https://go.dev/dl/go1.19.11.src.tar.gz
  mkdir go-bootstrap
  tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
  cd ./go-bootstrap/src/
  bash make.bash
  cd ../../
  wget https://go.dev/dl/go1.20.6.src.tar.gz
  mkdir go
  tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
  printf "gitdir: ../../does/not/exist/.git" > ./.git
  cd ./go/src/
  GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The build fails with the following error:

  Building Go toolchain1 using [snip]/go-1.19.10.
  error obtaining VCS status: exit status 128
    Use -buildvcs=false to disable VCS stamping.
  go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go \
    compiler_bootstrap purego bootstrap/cmd/...: exit status 1

This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We
don't need the revision information in those binaries anyway. Setting this flag
was previously not done as we were unsure if the go-bootstrap compiler would be
new enough to support the buildvcs build flag. Since Go 1.20.x, Go 1.19.x is the
minimum version for go-bootstrap, and supports -buildvcs=false. We can now set
-buildvcs=false without worrying about compatibility.

Related: golang#54852
Fixes: golang#61620
@paralin paralin changed the title cmd/dist: set buildvcs=false if compiling outside of a Git directory cmd/dist: set buildvcs=false unconditionally for go-bootstrap Jul 28, 2023
@paralin paralin changed the title cmd/dist: set buildvcs=false unconditionally for go-bootstrap cmd/dist: fails with buildvcs=false errors if invalid .git exists in parent of GOROOT_BOOTSTRAP Jul 28, 2023
paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction
paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction
paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction
paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction

v2 -> v3:

 - drop unnecessary go.mk change
@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jul 28, 2023
@paralin
Copy link
Contributor Author

paralin commented Jul 28, 2023

Reproduction using go master (go1.22) which requires go1.20 as go-bootstrap:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go-bootstrap
tar -xf go1.20.6.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
git clone https://go.googlesource.com/go
rm -rf ./go/.git/
printf "gitdir: ../../does/not/exist/.git" > ./.git
printf 'go1.22.1' > ./go/VERSION
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash
# Build fails using -buildvcs=false errors.

paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction

v2 -> v3:

 - drop unnecessary go.mk change
paralin added a commit to skiffos/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>

---

v1 -> v2:

 - sort HOST_GO_MAKE_ENV alphabetically
 - simplify the patch to set buildvcs=false unconditionally for go-bootstrap
 - create a minimal reproduction of the issue
 - simplify the commit message with the minimal reproduction

v2 -> v3:

 - drop unnecessary go.mk change
arnout pushed a commit to buildroot/buildroot that referenced this issue Jul 28, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
@bcmills
Copy link
Contributor

bcmills commented Aug 8, 2023

https://go.dev/cl/432435 was intended to take care of exactly this problem.
I suspect that the problem is that cfg.GOROOT is set to a cleaned path, whereas in this reproducer GOROOT_BOOTSTRAP is explicitly set to a non-clean path.

That said, now that the minimum bootstrap Go version is 1.20 (and we can therefore assume that the -buildvcs flag exists), I agree that it is cleaner to set -buildvcs explicitly.

@paralin
Copy link
Contributor Author

paralin commented Aug 8, 2023

@bcmills It was intended to take care of it, and did successfully, however as of Go 1.20 it's not working again (thus my PR).

citral23 pushed a commit to citral23/buildroot that referenced this issue Sep 18, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
arnout pushed a commit to buildroot/buildroot that referenced this issue Oct 8, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit bc8e70a)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
agners pushed a commit to home-assistant/buildroot that referenced this issue Oct 17, 2023
Building host-go within docker fails:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Reproduction of the issue:

mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash

The error only occurs when the .git that git detects in the parent directory of
the GOROOT_BOOTSTRAP is invalid or not present causing errors when running `git`
commands within GOROOT_BOOTSTRAP.

Report: https://lists.buildroot.org/pipermail/buildroot/2023-July/671344.html
Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
Upstream issue: golang/go#61620
Upstream PR: golang/go#61621

Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit bc8e70a)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
@seankhliao seankhliao added this to the Unplanned milestone Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants