From 735a960cdab8da1a65e1568bb2b284ef6d21ad86 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 2 Oct 2019 23:50:19 -0400 Subject: [PATCH] Fixes "Could not create directory ...classes.bak" Fixes https://github.com/sbt/sbt/issues/1673 There's been report of intermittent "Could not create directory" error related to "classes.bak." retronym identified that all configurations are using the same directory, and that might be the cause of race condition. This addresses the issue by assigning a unique directory for each configuration. --- main/src/main/scala/sbt/Defaults.scala | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 97bce5bf5..b9eb595c6 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -471,13 +471,6 @@ object Defaults extends BuildCommon { // This is included into JvmPlugin.projectSettings def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq( - incOptions := incOptions.value - .withClassfileManagerType( - Option( - TransactionalManagerType - .of(crossTarget.value / "classes.bak", sbt.util.Logger.Null): ClassFileManagerType - ).toOptional - ), scalaInstance := scalaInstanceTask.value, crossVersion := (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled), sbtBinaryVersion in pluginCrossBuild := binarySbtVersion( @@ -657,7 +650,20 @@ object Defaults extends BuildCommon { prev + (version -> (dependencyClasspathFiles / outputFileStamps).value) }, compileBinaryFileInputs := compileBinaryFileInputs.triggeredBy(compile).value, - incOptions := { incOptions.value.withExternalHooks(externalHooks.value) }, + incOptions := { + val old = incOptions.value + old + .withExternalHooks(externalHooks.value) + .withClassfileManagerType( + Option( + TransactionalManagerType + .of( // https://github.com/sbt/sbt/issues/1673 + crossTarget.value / s"${prefix(configuration.value.name)}classes.bak", + sbt.util.Logger.Null + ): ClassFileManagerType + ).toOptional + ) + }, compileIncSetup := compileIncSetupTask.value, console := consoleTask.value, collectAnalyses := Definition.collectAnalysesTask.map(_ => ()).value,