-
Notifications
You must be signed in to change notification settings - Fork 573
Open
Labels
Description
Describe the bug
I reported pre-commit/pre-commit#3512 after our pre-commit jobs started failing on the terraform-docs hook. This appears to be a compatibility issue with Golang 1.25, which was recently released and I believe what's happening is that pre-commit
's golang module automatically started using 1.25.0 as soon as it was listed on go.dev when running on a system where go
was not in the path:
I have avoided this by adding Go 1.24 to the container where our pre-commit hooks run (Amazon Linux 2023 currently ships Go 1.24.x)
How can we reproduce it?
This appears to be golang/go#74462:
…
go: downloading golang.org/x/sync v0.11.0
go: downloading golang.org/x/mod v0.21.0
# golang.org/x/tools/internal/tokeninternal
golangenv-default/pkg/mod/golang.org/x/tools@v0.25.0/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)
$ podman run --rm -it --entrypoint /bin/bash public.ecr.aws/amazonlinux/amazonlinux:2023
Trying to pull public.ecr.aws/amazonlinux/amazonlinux:2023...
Getting image source signatures
Copying blob sha256:93b5cbbc86ee614f8432762e1f7f34b6cc9d6d4b95867cf25bca6ae179f49439
Copying config sha256:63726c99a334375442ad8adfe25bf06914f1f94ee1ea995ba008c74256a5cf82
Writing manifest to image destination
bash-5.2# cd $(mktemp -d)
bash-5.2# cat > .pre-commit-config.yaml
repos:
- repo: https://github.com/terraform-docs/terraform-docs
rev: "v0.20.0"
hooks:
- id: terraform-docs-go
bash-5.2# dnf install -qy python3.13-pip git
bash-5.2# python3.13 -m pip install pre-commit
Collecting pre-commit
…
bash-5.2# git init
Initialized empty Git repository in /tmp/tmp.ViG1lTrYWt/.git/
bash-5.2# pre-commit install-hooks
[INFO] Initializing environment for https://github.com/terraform-docs/terraform-docs.
[INFO] Installing environment for https://github.com/terraform-docs/terraform-docs.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/root/.cache/pre-commit/repofr32495j/golangenv-default/.go/bin/go', 'install', './...')
return code: 1
stdout: (none)
stderr:
go: downloading github.com/spf13/cobra v1.8.1
go: downloading github.com/BurntSushi/toml v1.4.0
go: downloading github.com/iancoleman/orderedmap v0.3.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/spf13/viper v1.19.0
go: downloading github.com/hashicorp/go-plugin v1.6.1
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/imdario/mergo v0.3.16
go: downloading honnef.co/go/tools v0.3.2
go: downloading github.com/hashicorp/go-hclog v1.6.3
go: downloading github.com/Masterminds/sprig/v3 v3.3.0
go: downloading mvdan.cc/xurls/v2 v2.5.0
go: downloading github.com/hashicorp/hcl/v2 v2.22.0
go: downloading github.com/terraform-docs/terraform-config-inspect v0.0.0-20210728164355-9c1f178932fa
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading github.com/spf13/cast v1.7.0
go: downloading github.com/golang/protobuf v1.5.4
go: downloading github.com/hashicorp/yamux v0.1.1
go: downloading github.com/mitchellh/go-testing-interface v1.14.1
go: downloading github.com/oklog/run v1.1.0
go: downloading google.golang.org/grpc v1.66.2
go: downloading golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e
go: downloading golang.org/x/tools v0.25.0
go: downloading golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
go: downloading github.com/fatih/color v1.17.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading dario.cat/mergo v1.0.1
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.3.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/huandu/xstrings v1.5.0
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.4.0
go: downloading golang.org/x/crypto v0.35.0
go: downloading github.com/zclconf/go-cty v1.15.0
go: downloading golang.org/x/sys v0.30.0
go: downloading golang.org/x/text v0.22.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.7
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading google.golang.org/protobuf v1.34.2
go: downloading golang.org/x/net v0.36.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/agext/levenshtein v1.2.3
go: downloading github.com/apparentlymart/go-textseg/v15 v15.0.0
go: downloading github.com/mitchellh/go-wordwrap v1.0.1
go: downloading golang.org/x/sync v0.11.0
go: downloading github.com/google/go-cmp v0.6.0
go: downloading golang.org/x/mod v0.21.0
# golang.org/x/tools/internal/tokeninternal
golangenv-default/pkg/mod/golang.org/x/tools@v0.25.0/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)
Check the log at /root/.cache/pre-commit/pre-commit.log
bash-5.2#
Environment information
go 1.25.0
terraform-docs 0.20.0
johnburns320, pritho and rbeuque74