SBT 无法在 ARM64 Apple 芯片上启动并出现错误找不到所需的组件“xsbti”

问题描述

当我使用命令启动 SBT 1.5 时,该命令又会为项目启动 0.13 版

❯ sbt -v
[sbt_options] declare -a sbt_options='()'
[process_args] java_version = '8'
# Executing command line:
java
-Dfile.encoding=UTF-8
-xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-jar
/opt/homebrew/Cellar/sbt/1.5.0/libexec/bin/sbt-launch.jar

[info] Loading global plugins from /Users/viswanath/.sbt/0.13/plugins
[info] Updating {file:/Users/viswanath/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

我收到以下错误

[error] (compile:compileIncremental) sbt.InvalidComponent: Could not find required component 'xsbti'

在我的 MacBookPro 上,采用 ARM64 架构的 M1 处理器(又名 Apple 芯片)。有关如何解决此问题的任何线索?

注意:Bundled SBT 在 IntelliJ 上运行良好

解决方法

将项目的 SBT 版本升级到 1.5.0,问题就消失了。 See this githib issue for more information

或者,在 SBT 1.5.0 上使用 check this workaround 以交互模式启动 SBT。

sbt -Dsbt.boot.directory=/tmp/boot1 -Dsbt.launcher.coursier=false
,

尝试使用 SDKMAN

安装
curl -s "https://get.sdkman.io" | bash

source "$HOME/.sdkman/bin/sdkman-init.sh"

sdk install java

sdk install sbt

sbt compile