mirror of https://github.com/sbt/sbt.git
Merge pull request #6935 from eed3si9n/wip/temp-directories
[1.7.x] Fix sbt trying to delete /tmp on ARM Macs
This commit is contained in:
commit
1db7dd328a
|
|
@ -310,7 +310,7 @@ public class BootServerSocket implements AutoCloseable {
|
|||
return "sbt-load" + hash;
|
||||
} else {
|
||||
final String alternativeSocketLocation =
|
||||
System.getenv().getOrDefault("XDG_RUNTIME_DIR", "/tmp");
|
||||
System.getenv().getOrDefault("XDG_RUNTIME_DIR", System.getProperty("java.io.tmpdir"));
|
||||
final Path alternativeSocketLocationRoot =
|
||||
Paths.get(alternativeSocketLocation).resolve(".sbt");
|
||||
final Path locationForSocket = alternativeSocketLocationRoot.resolve("sbt-socket" + hash);
|
||||
|
|
|
|||
|
|
@ -101,10 +101,8 @@ private[sbt] object Load {
|
|||
val delegates = defaultDelegates
|
||||
val pluginMgmt = PluginManagement(loader)
|
||||
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
|
||||
System.setProperty(
|
||||
"swoval.tmpdir",
|
||||
System.getProperty("swoval.tmpdir", globalBase.getAbsolutePath.toString)
|
||||
)
|
||||
SysProp.setSwovalTempDir()
|
||||
SysProp.setIpcSocketTempDir()
|
||||
LoadBuildConfiguration(
|
||||
stagingDirectory,
|
||||
classpath,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ package sbt
|
|||
package internal
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.{ Path, Paths }
|
||||
import java.util.Locale
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
|
@ -220,4 +221,33 @@ object SysProp {
|
|||
|
||||
lazy val sbtCredentialsEnv: Option[Credentials] =
|
||||
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