You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

High Sierra系统安装sbt后运行触发java.io.IOException错误求助

解决High Sierra上sbt 1.1.0运行时的文件锁IO异常

我之前在macOS High Sierra上部署sbt的时候遇到过完全一样的问题,这个错误本质是sbt 1.1.0版本的全局文件锁机制和High Sierra的文件系统兼容性不匹配导致的,下面给你几个可行的解决办法:

方法1:升级sbt到兼容版本

sbt后续版本已经修复了这个系统兼容性问题,直接用Homebrew升级即可:

brew upgrade sbt

升级完成后,不用再手动指定路径运行,直接在终端输入sbt就能启动了——Homebrew会自动把sbt的可执行文件路径加入系统PATH,比手动找Cellar里的文件方便多了。

方法2:临时禁用全局锁(适合不想升级的情况)

如果暂时需要保留1.1.0版本,可以通过设置环境变量绕过全局锁检查:

export SBT_GLOBAL_LOCK=0
# 然后再运行sbt
sbt

要是想让这个设置永久生效,可以把export SBT_GLOBAL_LOCK=0添加到你的~/.bash_profile或者~/.zshrc文件里,下次打开终端就自动生效了。

方法3:检查运行目录是否为本地磁盘

另外还要确认一下你是不是在NAS、网络共享盘这类非本地磁盘目录下运行sbt?这类文件系统通常不支持sbt需要的文件锁操作,把项目移到本地磁盘(比如~/Documents目录下)再运行sbt试试。

最后附上你遇到的错误栈方便参考:

java.io.IOException: Operation not supported
	at sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
	at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:90)
	at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1115)
	at java.nio.channels.FileChannel.tryLock(FileChannel.java:1155)
	at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:88)
	at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:80)
	at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:99)
	at xsbt.boot.Using$.withResource(Using.scala:10)
	at xsbt.boot.Using$.apply(Using.scala:9)
	at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:60)
	at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
	at xsbt.boot.Locks$.apply0(Locks.scala:31)
	at xsbt.boot.Locks$.apply(Locks.scala:28)
	at xsbt.boot.Launch.locked(Launch.scala:238)
	at xsbt.boot.Launch.app(Launch.scala:147)
	at xsbt.boot.Launch.app(Launch.scala:145)
	at xsbt.boot.Launch$.run(Launch.scala:102)
	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
	at xsbt.boot.Launch$.launch(Launch.scala:117)
	at xsbt.boot.Launch$.apply(Launch.scala:18)
	at xsbt.boot.Boot$.runImpl(Boot.scala:41)
	at xsbt.boot.Boot$.main(Boot.scala:17)
	at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.IOException: Operation not supported

内容的提问来源于stack exchange,提问作者Bassirou Rabo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:22:20