M1 Macでsbt runしたときに発生したエラーと対処法メモ

環境

  • OS: macOS Monterey 12.0.1
  • Play Framework 2.8
  • sbt: 2.12.x

エラー

長いので一部抜粋

[error] java.lang.UnsatisfiedLinkError: /Users/user/Library/Caches/JNA/temp/jna685230223668778388.tmp: dlopen(/Users/user/Library/Caches/JNA/temp/jna685230223668778388.tmp, 0x0001): tried: '/Users/user/Library/Caches/JNA/temp/jna685230223668778388.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/jna685230223668778388.tmp' (no such file)
[error]   at java.lang.ClassLoader$NativeLibrary.load(Native Method)
[error]   at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1950)

対処内容

~/.sbt/boot/scala-x.xx.x/org.scala-sbt/sbt/jna-platform-x.x.x.jajna-x.x.x.jarを以下Githubの最新と置き換える。

https://github.com/java-native-access/jna#jna

参考