Repository navigation
command: go install fails with: error obtaining VCS status: exit status 128 while installing check #2722
Copy link
Copy link
Closed
Description
search you tried in the issue tracker
error obtaining VCS status: exit status
describe your issue
I was just running the pre-commit checks. It looks like the failures started after the update.
git commit -am "My ultimate commit"Output:
[INFO] Installing environment for https://github.com/stackrox/kube-linter.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
stdout: (none)
stderr:
go: downloading github.com/fatih/color v1.13.0
go: downloading github.com/Masterminds/sprig/v3 v3.2.3
go: downloading github.com/pkg/errors v0.9.1
...
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
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.
I have also tried to run: pre-commit clean but it did not help.
pre-commit --version
pre-commit 3.0.0
.pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: detect-aws-credentials
args:
- "--allow-missing-credentials"
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/stackrox/kube-linter
rev: 0.5.1
hooks:
- id: kube-linter
args: [lint, --config, .kube-linter.yaml]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
args: [-c=.yamllint]
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args:
[
"--disable-plugin",
"KeywordDetector",
"--baseline",
".secrets.baseline",
]
exclude: package.lock.json~/.cache/pre-commit/pre-commit.log (if present)
version information
pre-commit version: 3.0.0
git --version: git version 2.39.1
sys.version:
3.11.1 (main, Dec 23 2022, 09:28:24) [Clang 14.0.0 (clang-1400.0.29.202)]
sys.executable: /opt/homebrew/Cellar/pre-commit/3.0.0/libexec/bin/python3
os.name: posix
sys.platform: darwin
error information
An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
stdout: (none)
stderr:
go: downloading github.com/fatih/color v1.13.0
go: downloading github.com/Masterminds/sprig/v3 v3.2.3
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/ghodss/yaml v1.0.0
go: downloading github.com/spf13/cobra v1.6.1
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/owenrumney/go-sarif/v2 v2.1.2
go: downloading github.com/spf13/viper v1.14.0
go: downloading github.com/openshift/api v3.9.0+incompatible
go: downloading k8s.io/apimachinery v0.25.4
go: downloading k8s.io/api v0.25.4
go: downloading github.com/stretchr/testify v1.8.1
go: downloading helm.sh/helm/v3 v3.10.2
go: downloading k8s.io/gengo v0.0.0-20211129171323-c02415ce4185
go: downloading k8s.io/client-go v0.25.4
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/mattn/go-isatty v0.0.16
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.2.0
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/huandu/xstrings v1.3.3
go: downloading github.com/imdario/mergo v0.3.12
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.2.0
go: downloading github.com/spf13/cast v1.5.0
go: downloading golang.org/x/crypto v0.3.0
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading github.com/fsnotify/fsnotify v1.6.0
go: downloading github.com/spf13/afero v1.9.2
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/google/gofuzz v1.2.0
go: downloading k8s.io/klog/v2 v2.80.1
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.3
go: downloading k8s.io/utils v0.0.0-20220922133306-665eaaec4324
go: downloading sigs.k8s.io/yaml v1.3.0
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading github.com/BurntSushi/toml v1.2.1
go: downloading github.com/gobwas/glob v0.2.3
go: downloading github.com/cyphar/filepath-securejoin v0.2.3
go: downloading github.com/xeipuuv/gojsonschema v1.2.0
go: downloading k8s.io/apiextensions-apiserver v0.25.2
go: downloading golang.org/x/sys v0.2.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/subosito/gotenv v1.4.1
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.6
go: downloading github.com/pelletier/go-toml/v2 v2.0.5
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
go: downloading golang.org/x/text v0.4.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/go-logr/logr v1.2.3
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/pelletier/go-toml v1.9.5
go: downloading github.com/google/gnostic v0.6.9
go: downloading golang.org/x/net v0.2.0
go: downloading github.com/json-iterator/go v1.1.12
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading k8s.io/cli-runtime v0.25.4
go: downloading github.com/containerd/containerd v1.6.6
go: downloading github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
go: downloading github.com/sirupsen/logrus v1.9.0
go: downloading oras.land/oras-go v1.2.0
go: downloading google.golang.org/protobuf v1.28.1
go: downloading k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea
go: downloading golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
go: downloading golang.org/x/term v0.2.0
go: downloading golang.org/x/time v0.0.0-20220609170525-579cf78fd858
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading github.com/evanphx/json-patch v5.6.0+incompatible
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/docker/cli v20.10.17+incompatible
go: downloading github.com/docker/distribution v2.8.1+incompatible
go: downloading golang.org/x/sync v0.1.0
go: downloading github.com/docker/docker v20.10.17+incompatible
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading sigs.k8s.io/kustomize/api v0.12.1
go: downloading sigs.k8s.io/kustomize/kyaml v0.13.9
go: downloading github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
go: downloading github.com/peterbourgon/diskv v2.0.1+incompatible
go: downloading github.com/moby/locker v1.0.1
go: downloading google.golang.org/grpc v1.50.1
go: downloading github.com/emicklei/go-restful/v3 v3.8.0
go: downloading github.com/docker/docker-credential-helpers v0.6.4
go: downloading github.com/go-openapi/swag v0.19.14
go: downloading github.com/go-openapi/jsonreference v0.19.5
go: downloading github.com/google/btree v1.0.1
go: downloading github.com/klauspost/compress v1.14.1
go: downloading github.com/mailru/easyjson v0.7.6
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/go-openapi/jsonpointer v0.19.5
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/go-errors/errors v1.0.1
go: downloading github.com/josharian/intern v1.0.0
go: downloading google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/docker/go-metrics v0.0.1
go: downloading github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
go: downloading github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00
go: downloading github.com/xlab/treeprint v1.1.0
go: downloading github.com/docker/go-units v0.4.0
go: downloading github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
go: downloading github.com/morikuni/aec v1.0.0
go: downloading go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
go: downloading github.com/prometheus/client_golang v1.13.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/common v0.37.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/procfs v0.8.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
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.
Traceback (most recent call last):
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/main.py", line 366, in main
return hook_impl(
^^^^^^^^^^
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/commands/hook_impl.py", line 254, in hook_impl
return retv | run(config, store, ns)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/commands/run.py", line 436, in run
install_hook_envs(to_install, store)
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 239, in install_hook_envs
_hook_install(hook)
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 86, in _hook_install
lang.install_environment(
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/languages/golang.py", line 152, in install_environment
helpers.run_setup_cmd(prefix, ('go', 'install', './...'), env=env)
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/languages/helpers.py", line 49, in run_setup_cmd
cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
File "/opt/homebrew/Cellar/pre-commit/3.0.0/libexec/lib/python3.11/site-packages/pre_commit/util.py", line 115, in cmd_output_b
raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
stdout: (none)
stderr:
go: downloading github.com/fatih/color v1.13.0
go: downloading github.com/Masterminds/sprig/v3 v3.2.3
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/ghodss/yaml v1.0.0
go: downloading github.com/spf13/cobra v1.6.1
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/owenrumney/go-sarif/v2 v2.1.2
go: downloading github.com/spf13/viper v1.14.0
go: downloading github.com/openshift/api v3.9.0+incompatible
go: downloading k8s.io/apimachinery v0.25.4
go: downloading k8s.io/api v0.25.4
go: downloading github.com/stretchr/testify v1.8.1
go: downloading helm.sh/helm/v3 v3.10.2
go: downloading k8s.io/gengo v0.0.0-20211129171323-c02415ce4185
go: downloading k8s.io/client-go v0.25.4
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/mattn/go-isatty v0.0.16
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.2.0
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/huandu/xstrings v1.3.3
go: downloading github.com/imdario/mergo v0.3.12
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.2.0
go: downloading github.com/spf13/cast v1.5.0
go: downloading golang.org/x/crypto v0.3.0
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading github.com/fsnotify/fsnotify v1.6.0
go: downloading github.com/spf13/afero v1.9.2
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/google/gofuzz v1.2.0
go: downloading k8s.io/klog/v2 v2.80.1
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.3
go: downloading k8s.io/utils v0.0.0-20220922133306-665eaaec4324
go: downloading sigs.k8s.io/yaml v1.3.0
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading github.com/BurntSushi/toml v1.2.1
go: downloading github.com/gobwas/glob v0.2.3
go: downloading github.com/cyphar/filepath-securejoin v0.2.3
go: downloading github.com/xeipuuv/gojsonschema v1.2.0
go: downloading k8s.io/apiextensions-apiserver v0.25.2
go: downloading golang.org/x/sys v0.2.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/subosito/gotenv v1.4.1
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.6
go: downloading github.com/pelletier/go-toml/v2 v2.0.5
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
go: downloading golang.org/x/text v0.4.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/go-logr/logr v1.2.3
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/pelletier/go-toml v1.9.5
go: downloading github.com/google/gnostic v0.6.9
go: downloading golang.org/x/net v0.2.0
go: downloading github.com/json-iterator/go v1.1.12
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading k8s.io/cli-runtime v0.25.4
go: downloading github.com/containerd/containerd v1.6.6
go: downloading github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
go: downloading github.com/sirupsen/logrus v1.9.0
go: downloading oras.land/oras-go v1.2.0
go: downloading google.golang.org/protobuf v1.28.1
go: downloading k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea
go: downloading golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
go: downloading golang.org/x/term v0.2.0
go: downloading golang.org/x/time v0.0.0-20220609170525-579cf78fd858
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading github.com/evanphx/json-patch v5.6.0+incompatible
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/docker/cli v20.10.17+incompatible
go: downloading github.com/docker/distribution v2.8.1+incompatible
go: downloading golang.org/x/sync v0.1.0
go: downloading github.com/docker/docker v20.10.17+incompatible
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading sigs.k8s.io/kustomize/api v0.12.1
go: downloading sigs.k8s.io/kustomize/kyaml v0.13.9
go: downloading github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
go: downloading github.com/peterbourgon/diskv v2.0.1+incompatible
go: downloading github.com/moby/locker v1.0.1
go: downloading google.golang.org/grpc v1.50.1
go: downloading github.com/emicklei/go-restful/v3 v3.8.0
go: downloading github.com/docker/docker-credential-helpers v0.6.4
go: downloading github.com/go-openapi/swag v0.19.14
go: downloading github.com/go-openapi/jsonreference v0.19.5
go: downloading github.com/google/btree v1.0.1
go: downloading github.com/klauspost/compress v1.14.1
go: downloading github.com/mailru/easyjson v0.7.6
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/go-openapi/jsonpointer v0.19.5
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/go-errors/errors v1.0.1
go: downloading github.com/josharian/intern v1.0.0
go: downloading google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/docker/go-metrics v0.0.1
go: downloading github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
go: downloading github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00
go: downloading github.com/xlab/treeprint v1.1.0
go: downloading github.com/docker/go-units v0.4.0
go: downloading github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
go: downloading github.com/morikuni/aec v1.0.0
go: downloading go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
go: downloading github.com/prometheus/client_golang v1.13.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/common v0.37.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/procfs v0.8.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
asottile commentedon Jan 25, 2023
it works fine for me in both 2.21 and 3.0 -- do you have any other
GOenvironment variables or other things interfering?pestanko commentedon Jan 26, 2023
I am not sure what the cause might be.
One thing I have noticed is when I was doing interactive rebase with renaming commit, the pre-commit check installation/initialization succeeded - what comes to my mind - maybe some timeouts?
Additional information:
Git version:
2.39.1This is my
go envasottile commentedon Jan 26, 2023
my guess is the error was needing to upgrade macos CLT or whatever. either way it's working now
zedtux commentedon Feb 15, 2023
I'm facing this error right now on my Linux box while it works perfectly on my macOS box.
I'm running Elementary OS 6 (Ubuntu Focal like) and I did install it using
pip.asottile commentedon Feb 15, 2023
can you share the same information as above? -- generally this failure isn't a pre-commit problem and is instead a misconfiguration of
gozedtux commentedon Feb 15, 2023
Sure, here it is :
Additional information:
Git version:
2.25.1go envfails for me as it is not installed!asottile commentedon Feb 15, 2023
yeah I need your config and everything else too
zedtux commentedon Feb 15, 2023
Oops, sorry :
pre-commit --version
pre-commit 3.0.4.pre-commit-config.yaml
~/.cache/pre-commit/pre-commit.log if present
version information
error information
asottile commentedon Feb 15, 2023
can you share
env | grep -Ei '(GIT|PRE_COMMIT|GO)' | sort, your~/.gitconfigandls -al ~/.cache/pre-commit?zedtux commentedon Feb 15, 2023
env | grep -Ei '(GIT|PRE_COMMIT|GO)' | sort
~/.gitconfig
ls -al ~/.cache/pre-commit
asottile commentedon Feb 16, 2023
tried reproducing in docker and didn't really get anywhere -- any chance you could strace and see what
gitcommand go is running and why it fails?awartoft commentedon Mar 13, 2023
I'm getting this on MacOS so I can't use strace for me is failing on the same package just a slightly different version.
colindean commentedon Apr 3, 2023
I'm encountering this now.
Workaround
I'm able to circumvent this problem by committing once like so:
After this succeeded, if I run
pre-commit clean && pre-commit install-hooks, I don't see the error again. I'd expect to see it, so I might be doing something odd here. I expected to have to doafter
pre-commit clean.Research and observations
Some research indicates that it's related to one or more of the following:
safe.directoryPossible remedies
-buildvcs=falsehere, perhaps with end-user control of itgo get && git config --global --add safe.directory ${where_go_get_put_it} && go install ${where_go_get_put_it}; I'm not a Go dev so 🤷See also:
Requested troubleshooting information
version information
error information
env | grep -Ei '(GIT|PRE_COMMIT|GO)' | sortls -al ~/.cache/pre-commit.pre-commit-config.yaml
Adds a system-provided checkmake hook for pre-commit
Adds precommit config
Use local checkmake since pre-commit doesn't compile the go right
colindean commentedon Apr 13, 2023
I'm encountering this on Linux, too.
asottile commentedon Apr 13, 2023
can you strace and figure out why git is mad?
colindean commentedon Apr 13, 2023
I can try. I've not used strace before, though.
One thing I've noticed on this Linux system is that if I run
pre-commit install-hooks, the checkmake hook will install correctly and run fine next time I rungit commit.If I run
pre-commit cleanand thengit commit, pre-commit prepares the hooks and fails with the above error. If I then runpre-commit install-hooksand try to commit again, it works.What's the difference in environment between when pre-commit needs to install hooks at commit time versus what happens when
install-hooksdoes its thing?asottile commentedon Apr 13, 2023
there shouldn't be a difference -- I haven't been able to reproduce the findings either way
colindean commentedon Apr 13, 2023
strace git commit -avoutput:but I think strace isn't attaching to the process(es) launched from
.git/hooks/pre-commit, so I altered that to inject strace:The output log is 22 MB. I'm pretty lost in it with the time I have available right now. I've attached it as a ~2.9 MB gzip. Hopefully I'm not leaking anything in this; this Linux system is actually WSL and there's virtually nothing on it.
pre-commit.strace.log.gz
asottile commentedon Apr 13, 2023
I think with
-ffand-oyou can get it to follow subprocesses which might help?sarndt commentedon Apr 28, 2023
I've run into the same problem, this post actually fixed the issue for me too.
So running
Running
pre-commit install-hooksfor some reason is able to download the go-modules when pre-commit is not possible to do so when just running a normalgit commitcommandznerd commentedon Jun 30, 2023
I'm running into the same issue while running
git commitThis workaround worked for me: prefix the
git commitcommand withGOFLAGS=-buildvcs=false.matthewhughes934 commentedon Feb 13, 2024
I just ran into this. I believe the cause is the fact
go installis called with a copy of the environmentpre-commit/pre_commit/languages/golang.py
Line 144 in 15bd0c7
GIT_INDEX_FILEwhengit commitis being run. Here's a reproduction usingpre-commit(tested onpre-commit 3.3.3,go version go1.21.6 linux/amd64, though I expect the same behaviour for any Go version >=1.18when Go started including VCS info in builds):GOFLAGS='-x'forcesgoto print commands as it runs them and reports:Note the line
fatal: unable to read 715dc4303df786fdbed5723d06fcca76ba0c9138:/tmp/tmp.o1rMm1SgXK/pre-commit-cache/repopbyr_tp4is the clone of the repo we're trying to build, but715dc4303df786fdbed5723d06fcca76ba0c9138is a blob in the repo we're committing in.Maybe the env needs to be cleaned with something like
pre-commit/pre_commit/git.py
Line 27 in 15bd0c7
go install? Or, as others have noted setting thebuildvcsbuild flag:go install -buildvcs=false ./...Here's a standalone reproduction, install this under
.git/hooks/pre-commitand rungo commit -awithGOCACHEandGOMODCACHEpointing to some clean caches (like above, sogoactually tries to build something, and doesn't just reuse the cache):NOTE: I found this didn't reproduce unless the
-a/--allflag was passed togit commit: in this caseGIT_INDEX_FILEwould be an absolute path likeGIT_INDEX_FILE=/tmp/repo/.git/index.lockbut otherwise might be a relative path like:GIT_INDEX_FILE=.git/indexin which case things can actually work.asottile commentedon Feb 18, 2024
finally a reproduction! thank you this should be easy enough to fix with the git helper