-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
go1.17 arm64 fails with can't load fmt error (>= 1.45.0) #2673
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
I have the same issue on darwin arm64. |
@WorkerYifei you have the same kind of problem, ok, but could you provide more information about your context?
To help, it's important to provide more and new information when you comment on an issue. |
@ldez Sorry for the late reply.
I'm using the
N/A
I think it's not related to my code. I can't even run the
I'm not familiar with I hope it helps. |
By the way, It works good on my Mac with Intel chip when environment and configuration not changed. |
I'm seeing the same issue with Go 1.17.6 and golangci-lint 1.45.2 and 1.45.0 on M1 MBP panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
github.com/go-critic/go-critic@v0.6.2/checkers/embedded_rules.go:46 +0x494
make: *** [lint] Error 2 Works fine if I downgrade to 1.44.2 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Any update? (not quite same as #2374) On arm (m1) with golang 1.17.9 1.44.2 works, 1.45.2 doesn't: $ docker build -f Dockerfile.lint_bug .
[+] Building 13.7s (7/7) FINISHED
=> [internal] load build definition from Dockerfile.lint_bug 0.0s
=> => transferring dockerfile: 411B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/golang:1.17.9 2.3s
=> [auth] library/golang:pull token for registry-1.docker.io 0.0s
=> CACHED [1/3] FROM docker.io/library/golang:1.17.9@sha256:c1bf2101f7e1e0b08ce8f792735a81cd71b9d81cbcdceef2382140694f1ffbaf 0.0s
=> [2/3] RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2 6.0s
=> ERROR [3/3] RUN golangci-lint version 5.3s
------
> [3/3] RUN golangci-lint version:
#7 5.277 panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
#7 5.277
#7 5.277 goroutine 1 [running]:
#7 5.277 github.com/go-critic/go-critic/checkers.init.22()
#7 5.277 github.com/go-critic/go-critic@v0.6.2/checkers/embedded_rules.go:46 +0x488
------
executor failed running [/bin/sh -c golangci-lint version]: exit code: 2 With this Dockerfile: FROM golang:1.17.9
# golangci-lint
# See https://github.com/golangci/golangci-lint/issues/2374
# Use 1.44.2 which works on arm while 1.45.2 doesn't... somehow
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
RUN golangci-lint version |
Could you try with the binary of go-critic? |
What do you mean? (or how?) I'm using the https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh which is a binary release of everything bundled together I believe? if I install from source it does work go1.17.9 install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
~/go/bin/golangci-lint version
golangci-lint has version v1.45.2 built from (unknown, mod sum: "h1:9I3PzkvscJkFAQpTQi5Ga0V4qWdJERajX1UZ7QqkW+I=") on (unknown) but I'm trying to follow "don't install from source" from https://golangci-lint.run/usage/install/#local-installation |
The problem seems related to go-critic (see your logs), then can you try with the go-critic binary? |
I am not familiar with golangci internals but doing this FROM golang:1.17.9
RUN go install github.com/go-critic/go-critic/cmd/gocritic@v0.6.3
RUN gocritic version
# golangci-lint
# See https://github.com/golangci/golangci-lint/issues/2673
# Use 1.44.2 which works on arm while 1.45.2 doesn't... somehow
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
RUN golangci-lint version doesn't help; it still uses 0.6.2 note that anyone can reproduce this even without arm machine, did you try?
|
I'm asking you to run the go-critic binary in your container. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Again, I'm not compiling golangci-lint; I'm using the binary install script per instructions How is it off topic to flag that the install script doesn't work with arm? also your link is about running a 1.17 build along 1.18 and 1.18 support. I'm only using 1.17.9, no 1.18 involved |
Sorry, it's late for me, I misread. Can you run the go-critic binary in your container? |
go-critic seems to have a problem since v0.6.2, the binaries are missing. |
$ docker run --platform linux/arm64 -ti -v `pwd`:/build golang:1.17.9 /bin/bash
root@d4548d5f6d6c:/go# cd /build/
root@d4548d5f6d6c:/build# go install github.com/go-critic/go-critic/cmd/gocritic@v0.6.3
go: downloading github.com/go-critic/go-critic v0.6.3
go: downloading github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5
go: downloading golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da
go: downloading github.com/go-toolsmith/astfmt v1.0.0
go: downloading github.com/go-toolsmith/astcast v1.0.0
go: downloading github.com/go-toolsmith/astcopy v1.0.0
go: downloading github.com/go-toolsmith/astequal v1.0.1
go: downloading github.com/go-toolsmith/astp v1.0.0
go: downloading github.com/go-toolsmith/strparse v1.0.0
go: downloading github.com/go-toolsmith/typep v1.0.2
go: downloading github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a
go: downloading github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95
go: downloading github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5
go: downloading github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567
go: downloading golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
go: downloading golang.org/x/mod v0.5.1
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
root@d4548d5f6d6c:/build# gocritic check ./fnet
./fnet/network.go:469:9: elseif: can replace 'else {if cond {}}' with 'else if cond {}'
./fnet/network.go:210:2: ifElseChain: rewrite if-else to switch statement
./fnet/network.go:508:2: ifElseChain: rewrite if-else to switch statement
root@d4548d5f6d6c:/build# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
golangci/golangci-lint info checking GitHub for tag 'v1.45.2'
golangci/golangci-lint info found version: 1.45.2 for v1.45.2/linux/arm64
golangci/golangci-lint info installed /go/bin/golangci-lint
root@d4548d5f6d6c:/build# golangci-lint version
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
github.com/go-critic/go-critic@v0.6.2/checkers/embedded_rules.go:46 +0x488 So gocritic by itself is fine, and I don't want to switch to 1.18 yet |
You have to compile go-critic with go1.18, because golangci-lint is compiled with go1.18. |
works fine btw, it's just the binary distribution which isn't working if you mean to say that golangci-lint 1.45.* binaries are not supported / meant to work with go1.17.* or at least mention it in install docs and the release notes? ("go1.18 support" isn't the same as "only >= 1.18 supported in binary releases" (on arm - it's odd it's only a problem on arm though)) maybe it's a bug of golang to not be backward compatible or arm only bug? |
I'm able to use golangci-lint 1.45.* binaries with go1.17 on linux/amd64 without any problem. My recommendation: use our official Docker image, and set 1.17 in your configuration: run:
go: '1.17' https://golangci-lint.run/usage/configuration/#run-configuration |
try for clarity and others stepping on this problem maybe rename this Issue as "go1.17 linux/arm64, binary distribution (install.sh) of golangci-lint >= 1.45 fails with panic can't load fmt" repro (as above, see docker file and command line or: [edit: that's not a very good example as it also fails with 1.44.2 because no go is installed] - so only see Dockerfile above] $ docker run --platform linux/arm64 -ti ubuntu:focal /bin/bash
root@f3af5e9bc2ca:/# apt-get update && apt-get install curl
[...]
root@f3af5e9bc2ca:/# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s
golangci/golangci-lint info checking GitHub for latest tag
golangci/golangci-lint info found version: 1.45.2 for v1.45.2/linux/arm64
golangci/golangci-lint info installed ./bin/golangci-lint
root@f3af5e9bc2ca:/# bin/golangci-lint
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
github.com/go-critic/go-critic@v0.6.2/checkers/embedded_rules.go:46 +0x488 |
Can you try to compile go-critic on arm64 with go1.18, and run the resulting binary with go1.17? |
FROM golang:1.18.1 as build
RUN go install github.com/go-critic/go-critic/cmd/gocritic@v0.6.3
FROM golang:1.17.9
COPY --from=build /go/bin/gocritic /usr/bin/gocritic
RUN gocritic version
COPY . test
WORKDIR test
RUN gocritic check ./... works fine so it's not go-critic... but replacing with FROM golang:1.18.1 as build
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
RUN golangci-lint version
FROM golang:1.17.9
COPY --from=build /go/bin/golangci-lint /usr/bin/golangci-lint
RUN golangci-lint version also works so it's not go 1.18 issue either it seems it's just that binary for arm is build wrong somehow? |
I noticed the non working one was statically linked, so tried FROM golang:1.18.0 as build
WORKDIR /build
RUN git clone https://github.com/golangci/golangci-lint
WORKDIR /build/golangci-lint
RUN git checkout v1.45.2
RUN CGO_ENABLED=0 go build -a -ldflags="-s" ./cmd/golangci-lint
RUN ./golangci-lint version
FROM golang:1.17.9
COPY --from=build /build/golangci-lint/golangci-lint /usr/bin/golangci-lint-ok
RUN golangci-lint-ok version but that still works fine only the downloaded binary version seems wrong - how is it built? maybe just needs a rebuild? Same sizes root@411df4293551:/go# ls -l /usr/bin/gola*
-rwxr-xr-x 1 root root 22020096 Apr 18 00:29 /usr/bin/golangci-lint-ok
root@411df4293551:/go# ls -l /go/bin/golangci-lint
-rwxr-xr-x 1 root root 22020096 Apr 18 00:29 /go/bin/golangci-lint Same type: root@5166303f68ff:/go# file /usr/bin/golangci-lint-ok
/usr/bin/golangci-lint-ok: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=OQBaBGSZtjVeeTZPsGNG/RgzR11pjJ_DMcmU9nmJb/tyjYyVrudHH6uw1lUoax/hUc2RAsRdGPW-FthTam6, stripped
root@5166303f68ff:/go# file /go/bin/golangci-lint
/go/bin/golangci-lint: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=Fnqw9MbpEiPUd8Sqqxyf/hHoGkr7qVg18UvZu1M4J/gvFh7P10kiILuf5xFYDn/NurFFBAcKC9Z_e2GkmVF, stripped |
ping? maybe just a matter of rebuilding with latest gopackager? |
We will not rebuild, we consider the binaries as immutables for security reasons. |
thanks, I did mean bump the patch level, not change released artifacts |
Still broken for me on golangci-lint 1.46.2, with go 1.17.9. Go 1.18.2 works fine. |
Instead of packaging the upstream release, build it from source so we can avoid issues like golangci/golangci-lint#2649 and golangci/golangci-lint#2673 Signed-off-by: Alex Murray <murray.alex@gmail.com>
This comment was marked as off-topic.
This comment was marked as off-topic.
I had to work around a similar problem today, solution documented in golangci/golangci-lint-action#442 (comment). tl;dr build |
I've found some success in explicitly setting the Small example case to reproduce this (on an M1 arm64 host): FROM golang:1.17.8-alpine
RUN apk add --no-cache \
curl
ENV GOLANGCI_LINT_VERSION=v1.45.2
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
RUN golangci-lint version
ENTRYPOINT ["golangci-lint"] Gives:
However by adding FROM golang:1.17.8-alpine
RUN apk add --no-cache \
curl
ENV GOLANGCI_LINT_VERSION=v1.45.2
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
ENV GOROOT /usr/local/go
RUN golangci-lint version
ENTRYPOINT ["golangci-lint"]
Checking the |
…go:13: can't load fmt`. Proposed workaround: golangci/golangci-lint#2673 (comment)
…go:13: can't load fmt`. (#27) Proposed workaround: golangci/golangci-lint#2673 (comment)
closed in favor of #3107 |
The old version did not work because of the following problem. golangci/golangci-lint#2673
Per comment in golangci-lint thread: golangci/golangci-lint#2673 (comment)
Welcome
Description of the problem
golangci-lint version 1.45.0 on linux arm64/aarch64 with go1.17.8 fails with this error
golangci-lint version 1.45.0 works just fine on amd64 with go1.17.8, as well as arm64 with go1.18
Here's the whole process
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
N/A error occurs before running the linters, no code is being linted
The text was updated successfully, but these errors were encountered: