mirror of https://github.com/sbt/sbt.git
Fix sbt trying to delete /tmp on ARM Macs
Problem ------- There's a bug in ipcsocket cleanup logic that effectively tries to wipe out /tmp. Workaround ---------- We should fix the underlying bug, but we can start by explicitly configuring the temp directories ipcsocket uses. Ref https://github.com/sbt/sbt/issues/6931
This commit is contained in:
parent
4a006cb79d
commit
87dc5da93a
|
|
@ -310,7 +310,7 @@ public class BootServerSocket implements AutoCloseable {
|
||||||
return "sbt-load" + hash;
|
return "sbt-load" + hash;
|
||||||
} else {
|
} else {
|
||||||
final String alternativeSocketLocation =
|
final String alternativeSocketLocation =
|
||||||
System.getenv().getOrDefault("XDG_RUNTIME_DIR", "/tmp");
|
System.getenv().getOrDefault("XDG_RUNTIME_DIR", System.getProperty("java.io.tmpdir"));
|
||||||
final Path alternativeSocketLocationRoot =
|
final Path alternativeSocketLocationRoot =
|
||||||
Paths.get(alternativeSocketLocation).resolve(".sbt");
|
Paths.get(alternativeSocketLocation).resolve(".sbt");
|
||||||
final Path locationForSocket = alternativeSocketLocationRoot.resolve("sbt-socket" + hash);
|
final Path locationForSocket = alternativeSocketLocationRoot.resolve("sbt-socket" + hash);
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,8 @@ private[sbt] object Load {
|
||||||
val delegates = defaultDelegates
|
val delegates = defaultDelegates
|
||||||
val pluginMgmt = PluginManagement(loader)
|
val pluginMgmt = PluginManagement(loader)
|
||||||
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
|
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
|
||||||
System.setProperty(
|
SysProp.setSwovalTempDir()
|
||||||
"swoval.tmpdir",
|
SysProp.setIpcSocketTempDir()
|
||||||
System.getProperty("swoval.tmpdir", globalBase.getAbsolutePath.toString)
|
|
||||||
)
|
|
||||||
LoadBuildConfiguration(
|
LoadBuildConfiguration(
|
||||||
stagingDirectory,
|
stagingDirectory,
|
||||||
classpath,
|
classpath,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ package sbt
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.{ Path, Paths }
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
|
|
@ -220,4 +221,33 @@ object SysProp {
|
||||||
|
|
||||||
lazy val sbtCredentialsEnv: Option[Credentials] =
|
lazy val sbtCredentialsEnv: Option[Credentials] =
|
||||||
sys.env.get("SBT_CREDENTIALS").map(raw => new FileCredentials(new File(raw)))
|
sys.env.get("SBT_CREDENTIALS").map(raw => new FileCredentials(new File(raw)))
|
||||||
|
|
||||||
|
private[sbt] def setSwovalTempDir(): Unit = {
|
||||||
|
val _ = getOrUpdateSwovalTmpDir(
|
||||||
|
runtimeDirectory.resolve("swoval").toString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
private[sbt] def setIpcSocketTempDir(): Unit = {
|
||||||
|
val _ = getOrUpdateIpcSocketTmpDir(
|
||||||
|
runtimeDirectory.resolve("ipcsocket").toString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
private[this] lazy val getOrUpdateSwovalTmpDir: String => String =
|
||||||
|
getOrUpdateSysProp("swoval.tmpdir")(_)
|
||||||
|
private[this] lazy val getOrUpdateIpcSocketTmpDir: String => String =
|
||||||
|
getOrUpdateSysProp("sbt.ipcsocket.tmpdir")(_)
|
||||||
|
private[this] def getOrUpdateSysProp(key: String)(value: String): String = {
|
||||||
|
val newVal = sys.props.getOrElse(key, value)
|
||||||
|
sys.props += (key -> newVal)
|
||||||
|
newVal
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns a temporary directory that is friendly to macOS, Linux,
|
||||||
|
* Windows, and Docker environment.
|
||||||
|
* Mostly these directories will be used as throw-away location to extract
|
||||||
|
* native files etc.
|
||||||
|
*/
|
||||||
|
private[this] def runtimeDirectory: Path =
|
||||||
|
Paths.get(sys.env.getOrElse("XDG_RUNTIME_DIR", sys.props("java.io.tmpdir"))).resolve(".sbt")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue