shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Fails on apple M2 chip

Open christian-steinmeyer opened this issue 2 years ago • 7 comments

For bugs

  • My shellcheck version (shellcheck --version or "online"): 0.9.0
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)

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"

christian-steinmeyer avatar Feb 02 '23 16:02 christian-steinmeyer

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

mikhailnov avatar Feb 02 '23 19:02 mikhailnov

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.

moreaki avatar Feb 02 '23 20:02 moreaki

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

christian-steinmeyer avatar Feb 03 '23 07:02 christian-steinmeyer

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?

christian-steinmeyer avatar Feb 03 '23 07:02 christian-steinmeyer

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).

moreaki avatar Feb 03 '23 08:02 moreaki

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

christian-steinmeyer avatar Feb 06 '23 13:02 christian-steinmeyer

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

kaihowl avatar Oct 02 '23 16:10 kaihowl