koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.29k stars 1.77k forks source link

Fails on apple M2 chip #2680

Open christian-steinmeyer opened 1 year ago

christian-steinmeyer commented 1 year ago

For bugs

Here's a snippet or screenshot that shows the problem:

Running any shellcheck with any script on my M2 device yields currently yields the following error.

Here's what shellcheck currently says:

[Errno 86] Bad CPU type in executable


Note, that I run shellcheck via its pre-commit hook that "simply wraps the shellcheck binary"

mikhailnov commented 1 year ago

Of course it fails if you try to run an x86_64 binary on ARM (aarch64). Built it yourself.

moreaki commented 1 year ago

I've installed shellcheck via brew to check that it works:

$ brew install shellcheck
==> Fetching shellcheck
==> Downloading https://ghcr.io/v2/homebrew/core/shellcheck/manifests/0.9.0
[...]
==> Pouring shellcheck--0.9.0.arm64_ventura.bottle.tar.gz
🍺  /opt/homebrew/Cellar/shellcheck/0.9.0: 7 files, 65.8MB
==> Running `brew cleanup shellcheck`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$ shellcheck --version
ShellCheck - shell script analysis tool
version: 0.9.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net
$ sysctl -n machdep.cpu.brand_string
Apple M2

No need to actually compile anything.

christian-steinmeyer commented 1 year ago

Confirmed: When installed with brew, shellcheck works on my device. Question is, how do I get the pre-commit hook to work

christian-steinmeyer commented 1 year ago

Okay, as far as I can tell, the pre-commit hook uses one of the binaries provided as part of the releases, but currently, these only contain an x86 build for darwin, is that correct? Could it be an option to also build for arm and add that to the releases moving forward?

moreaki commented 1 year ago

Okay, as far as I can tell, the pre-commit hook uses one of the binaries provided as part of the releases, but currently, these only contain an x86 build for darwin, is that correct? Could it be an option to also build for arm and add that to the releases moving forward?

This is the runner's configuration for this project: https://github.com/koalaman/shellcheck/actions/runs/3682710473/workflow. I'm not certain how easy it would be to add arm64, but it should technically be available from GitHub's CI pipeline. Although, it might only be for arm64/linux or some QEMU-based infrastructure (which might not be sufficient).

According to https://github.com/actions/runner-images, the rollout progress is not quite there yet.

One additional option would be for you to support the project with a self-hosted runner: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners and https://www.pantsbuild.org/docs/ci-for-macos-on-arm64.

Or you could sponsor the integration of hosted ARM runners from BuildJet (https://buildjet.com/for-github-actions/blog/hosted-arm-runners-on-github-actions), which support a fast M1/M2 pipeline which does not cost too much. Maybe even on the orka platform (https://www.macstadium.com/orka).

christian-steinmeyer commented 1 year ago

I'm leaving the relevant github roadmap and tracking issue here as well: https://github.com/github/roadmap/issues/528 and https://github.com/rust-lang/rust/issues/73908

kaihowl commented 1 year ago

For the sake of completeness: Installing Rosetta explicitly also allows to use the released Intel macOS versions. Use sudo softwareupdate --install-rosetta.