Scala terminal launch error: Illegal instruction: 4

New to Scala and I installed Scala using homebrew. When I type scala in terminal, it is giving me the following error:

$ scala
Welcome to Scala 2.13.7 (OpenJDK 64-Bit Server VM, Java 17.0.1).
Type in expressions for evaluation. Or try :help.
/opt/homebrew/Cellar/scala/2.13.7/libexec/bin/scala: line 25: 53932 Illegal instruction: 4  "$@"

What might be the issue and how can I fix? I am using M1 Mac with Big Sur.


Solution 1:

It‘s probably https://github.com/scala/bug/issues/12491, though the error message you're seeing is a little different, which I find puzzling.

Assuming that's the problem, then: Scala 2.13.8 will be out soon (target: January 10) with a fix. In the meantime use 2.13.6, or launch 2.13.7 with -J-Dorg.jline.terminal.jna=false (but this may disable some terminal niceties), or use a 2.13.8 nightly build.