Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nondeterministic "No such file or directory" failure when cleaning project #2156

Closed
ghik opened this issue Aug 14, 2015 · 50 comments
Closed
Assignees
Labels
Milestone

Comments

@ghik
Copy link

ghik commented Aug 14, 2015

I'm not sure if this is the right place to report this - I'd rather put this first on some forum, but since SBT does not have any mailing list for users, I'm forced to put it here.

I'm randomly getting this error when trying to build my project:

[default-tests-sbt] $ /usr/lib/jvm/java-8-oracle/bin/java -Dsbt.log.noformat=true -Xmx2G -jar /var/lib/jenkins/tools/org.jvnet.hudson.plugins.SbtPluginBuilder_SbtInstallation/SBT_default_launcher/bin/sbt-launch.jar clean test:clean buildUmp test
[info] Loading project definition from /var/lib/jenkins/workspace/default-tests-sbt/project
[info] Set current project to ump (in build file:/var/lib/jenkins/workspace/default-tests-sbt/)
Could not create file /var/lib/jenkins/workspace/default-tests-sbt/launcher/target/streams/$global/ivyConfiguration/$global/streams/outjava.io.IOException: No such file or directory
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$mkIvyConfiguration$1.apply(Defaults.scala:1533)
    at sbt.Classpaths$$anonfun$mkIvyConfiguration$1.apply(Defaults.scala:1532)
    at scala.Function10$$anonfun$tupled$1.apply(Function10.scala:35)
    at scala.Function10$$anonfun$tupled$1.apply(Function10.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at sbt.IO$$anonfun$1.apply$mcZ$sp(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$mkIvyConfiguration$1.apply(Defaults.scala:1533)
    at sbt.Classpaths$$anonfun$mkIvyConfiguration$1.apply(Defaults.scala:1532)
    at scala.Function10$$anonfun$tupled$1.apply(Function10.scala:35)
    at scala.Function10$$anonfun$tupled$1.apply(Function10.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (launcher/*:ivyConfiguration) Could not create file /var/lib/jenkins/workspace/default-tests-sbt/launcher/target/streams/$global/ivyConfiguration/$global/streams/outjava.io.IOException: No such file or directory
[error] Total time: 76 s, completed 2015-08-14 13:05:08

Can anyone direct me how do I even troubleshoot/debug this?

@ghik
Copy link
Author

ghik commented Aug 28, 2015

Does anyone have an idea what may be causing this error? It's giving me nightmares - happens only sometimes, can't reliably reproduce it.

@lespea
Copy link

lespea commented Aug 28, 2015

Not an sbt expert but it seems like maybe it isn't creating parent directories or something? Also your path is under /var/lib is it a permissions issue on some parent folder you can't modify?

@ghik
Copy link
Author

ghik commented Aug 29, 2015

This only happens sometimes, so it's not a permission issue.

@eed3si9n
Copy link
Member

Do you have any plugins that checks for test coverage or coding styles?

@ghik
Copy link
Author

ghik commented Aug 31, 2015

No. The only plugins I have enabled are these:

resolvers += Resolver.url("jetbrains-bintray",
  url("http://dl.bintray.com/jetbrains/sbt-plugins/"))(Resolver.ivyStylePatterns)

addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "0.1.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.4")

@abbi-gaurav
Copy link

even I am seeing this failure randomly in my sbt builds.

Could not create file /home/jenkins/myjH/jobs/dummy-backend-common-build/workspace/source/test-utils/target/streams/$global/projectDescriptors/$global/streams/outjava.io.IOException: No such file or directory
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1516)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1515)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:35)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at sbt.IO$$anonfun$1.apply$mcZ$sp(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1516)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1515)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:35)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
�[0m[�[31merror�[0m] �[0m(*:�[31mprojectDescriptors�[0m) Could not create file /home/jenkins/myjH/jobs/dummy-backend-common-build/workspace/source/test-utils/target/streams/$global/projectDescriptors/$global/streams/outjava.io.IOException: No such file or directory�[0m
�[0m[�[31merror�[0m] �[0mTotal time: 0 s, completed Sep 15, 2015 11:28:08 AM�[0m
Build step 'Execute shell' marked build as failure

@ghik
Copy link
Author

ghik commented Sep 28, 2015

I would like to bring this again into attention.

This error completely ruins our builds and I haven't got a slightest idea how to debug or workaround it. I tried to do this:

def tryWorkAroundCrashingSbt(taskKey: TaskKey[_]): Setting[Task[TaskStreams]] = (streams in taskKey) := {
  val dirToCreate = target.value / s"streams/$$global/${taskKey.key.label}/$$global/streams"

  var i = 0
  while (!dirToCreate.exists() && i < 100) {
    if (i > 0) {
      streams.value.log.info(s"Trying ($i) to create $dirToCreate")
    }
    IO.createDirectory(dirToCreate)
    Thread.sleep(10)
    i += 1
  }

  if (!dirToCreate.exists()) {
    throw new Exception("Failed to create streams directory")
  }

  (streams in taskKey).value
}

and then adding to each subproject:

  tryWorkAroundCrashingSbt(ivyConfiguration),
  tryWorkAroundCrashingSbt(ivySbt),
  tryWorkAroundCrashingSbt(projectDescriptors)

But it doesn't work - still crashes randomly on various subprojects.

@eed3si9n
Copy link
Member

For us to work on this, we need to reproduce this on our machine (or Travis) by one way or another.
Could you explain (or create a demo project) of how your build looks like? How many subprojects do you have? Are they interconnected with each other? What does buildUmp do? Does it call clean within it?

The error says: Could not create file /var/lib/jenkins/workspace/default-tests-sbt/launcher/target/streams/$global/ivyConfiguration/$global/streams/outjava.io.IOException: No such file or directory, but is launcher one of your subproject? Is it always the same subproject that has this issue?

@ghik
Copy link
Author

ghik commented Sep 29, 2015

There's about 20 subprojects that depend on each other and the issue happens randomly in all subprojects, including the root one. Sometimes it even fails in more than one subproject at once.

Invoked tasks are clean buildUmp test and buildUmp is an aggregation task that performs compilation, packaging, copying jars and some custom processing tasks (e.g. minification of JS files). The failure happens during either of ivyConfiguration, ivySbt and projectDescriptors tasks.

I still have some random ideas for workarounds - I'll try them and maybe narrow the circumstances of that error a bit.

@ritschwumm
Copy link

first things first. does the file's parent directory exist when the exception is thrown?

@ghik
Copy link
Author

ghik commented Sep 29, 2015

SBT is supposed to create it. This is what it does (from sbt.IO):

def touch(file: File, setModified: Boolean = true) {
  val absFile = file.getAbsoluteFile
  createDirectory(absFile.getParentFile)
  val created = translate("Could not create file " + absFile) { absFile.createNewFile() }
  if (created || absFile.isDirectory)
    ()
  else if (setModified && !absFile.setLastModified(System.currentTimeMillis))
    sys.error("Could not update last modified time for file " + absFile)
}

@ghik
Copy link
Author

ghik commented Sep 30, 2015

So, I modified my workaround to do this:

def tryWorkAroundCrashingSbt(taskKey: TaskKey[_]): Setting[Task[TaskStreams]] = (streams in taskKey) := {
  val fileToCreate = target.value / s"streams/$$global/${taskKey.key.label}/$$global/streams/out"

  var i = 0
  var success = false
  while (!success && i < 100) {
    try {
      IO.touch(fileToCreate)
      success = fileToCreate.exists()
    } catch {
      case e: Exception =>
        streams.value.log.error("Failed to create file " + fileToCreate)
        e.printStackTrace()
    }
    i += 1
  }

  if (!success) {
    throw new Exception("Failed to create streams file " + fileToCreate)
  }
  streams.value.log.info("Created file " + fileToCreate + " after " + i + " trials")

  (streams in taskKey).value
}

and it still doesn't work. Here's what's happening now (project names and URLs have been edited):

[default-tests] $ /usr/lib/jvm/java-8-oracle/bin/java -Dsbt.log.noformat=true -Xmx2G -jar /var/lib/jenkins/tools/org.jvnet.hudson.plugins.SbtPluginBuilder_SbtInstallation/SBT_default_launcher/bin/sbt-launch.jar clean buildproj test
[info] Loading project definition from <http://rb.company.com/job/default-tests/ws/project>
[info] Set current project to proj (in build <http://rb.company.com/job/default-tests/ws/)>
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-macros/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-macros/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-macros/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv7/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv7/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv7/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-core/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv4/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv4/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv4/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv5/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv5/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv5/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv6/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv6/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv3/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv6/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-js/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv8/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-jvm/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv2/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-js/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv3/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-js/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv2/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv8/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv8/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv2/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-doc/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-util/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-jvm/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-doc/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-util/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv3/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-shared/target-jvm/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-doc/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[error] Failed to create file <http://rb.company.com/job/default-tests/ws/proj-util/target/streams/$global/ivyConfiguration/$global/streams/out>
Could not create file <http://rb.company.com/job/default-tests/ws/proj-util/target/streams/$global/ivyConfiguration/$global/streams/outjava.io.IOException>: No such file or directory
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at $fbefd52439d4cbd80a5a$$anonfun$tryWorkAroundCrashingSbt$1.apply(build.sbt:67)
    at $fbefd52439d4cbd80a5a$$anonfun$tryWorkAroundCrashingSbt$1.apply(build.sbt:60)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at sbt.IO$$anonfun$1.apply$mcZ$sp(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    ... 21 more
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-util/target/streams/$global/ivyConfiguration/$global/streams/out> after 2 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-core/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-core/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv9/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv9/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-serv9/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-dw/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-launcher/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-launcher/target/streams/$global/ivyConfiguration/$global/streams/out> after 2 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-launcher/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-migration/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-migration/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-dw/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[error] Failed to create file <http://rb.company.com/job/default-tests/ws/proj-mob-core/target/streams/$global/ivyConfiguration/$global/streams/out>
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-migration/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
java.lang.RuntimeException: Could not update last modified time for file <http://rb.company.com/job/default-tests/ws/proj-mob-core/target/streams/$global/ivyConfiguration/$global/streams/out>
    at scala.sys.package$.error(package.scala:27)
    at sbt.IO$.touch(IO.scala:147)
    at $fbefd52439d4cbd80a5a$$anonfun$tryWorkAroundCrashingSbt$1.apply(build.sbt:67)
    at $fbefd52439d4cbd80a5a$$anonfun$tryWorkAroundCrashingSbt$1.apply(build.sbt:60)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-mob-core/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-dw/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-rescl/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-rescl/target/streams/$global/ivySbt/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-mob-core/target/streams/$global/ivyConfiguration/$global/streams/out> after 2 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-rescl/target/streams/$global/ivyConfiguration/$global/streams/out> after 1 trials
[info] Created file <http://rb.company.com/job/default-tests/ws/proj-mob-core/target/streams/$global/projectDescriptors/$global/streams/out> after 1 trials
Could not create file <http://rb.company.com/job/default-tests/ws/proj-rescl/target/streams/$global/projectDescriptors/$global/streams/outjava.io.IOException>: No such file or directory
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1516)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1515)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:35)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at sbt.IO$$anonfun$1.apply$mcZ$sp(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.IO$$anonfun$1.apply(IO.scala:143)
    at sbt.ErrorHandling$.translate(ErrorHandling.scala:10)
    at sbt.IO$.touch(IO.scala:143)
    at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
    at sbt.std.Streams$$anon$3$$anon$2.text(Streams.scala:113)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:124)
    at sbt.std.TaskStreams$class.log(Streams.scala:56)
    at sbt.std.Streams$$anon$3$$anon$2.log$lzycompute(Streams.scala:102)
    at sbt.std.Streams$$anon$3$$anon$2.log(Streams.scala:102)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1516)
    at sbt.Classpaths$$anonfun$depMap$1.apply(Defaults.scala:1515)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:35)
    at scala.Function4$$anonfun$tupled$1.apply(Function4.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (proj-rescl/*:projectDescriptors) Could not create file <http://rb.company.com/job/default-tests/ws/proj-rescl/target/streams/$global/projectDescriptors/$global/streams/outjava.io.IOException>: No such file or directory
[error] Total time: 2 s, completed 2015-09-30 08:51:01

It's as if someone deleted the files that I just created...

@jsuereth
Copy link
Member

You may want to check your filesystem /tmp directory restrictions. It's possible you are unable to create the files and/or your filesystem is immediately cleaning them up.

@ghik
Copy link
Author

ghik commented Sep 30, 2015

/tmp directory does not seem to be used there or at least no error message mentions it. Is it used internally by SBT in a way that could cause these errors?

@ritschwumm
Copy link

another question: on which operating system do you see this behaviour?

@ghik
Copy link
Author

ghik commented Oct 1, 2015

Ubuntu 12.04 x86_64, kernel 3.2.0-72-generic, ext3 filesystem

@ghik
Copy link
Author

ghik commented Oct 2, 2015

Well, the problems seems to be gone after I disabled all concurrency in SBT:

concurrentRestrictions := Seq(Tags.limitAll(1))

There's still a chance it will fail, but I've had about 10 successful builds from then.

We don't need parallel builds, so it works for me, but I wouldn't count that as a solution or even workaround.

@pathikrit
Copy link

@gbougeard
Copy link

I have the same random issue on our CI.

@eed3si9n can you explain why it might be related to coverage or code style plugins?
@jsuereth idem about /tmp ?

@lespea
Copy link

lespea commented Dec 8, 2015

Can somebody who has this problem run strace when you launch sbt? Maybe that will shed light on what's happening...

strace -f -e trace=file sbt
{reproduce problem somehow}

@gbougeard
Copy link

if I could reproduce it easily I would but as it's random... :/

@lespea
Copy link

lespea commented Dec 8, 2015

How often does it happen? Could you live with the slowdown strace gives you until it happens randomly? Just change it to write to a file so it doesn't get lost in the noise haha

@pathikrit
Copy link

See my comment above. You can git clone https://github.com/pathikrit/better-files at hash = 4597e81e9faecc1676c85e7cbc1e5be8506b879a and run sbt clean test. Here's a run: https://circleci.com/gh/pathikrit/better-files/331

@eed3si9n
Copy link
Member

eed3si9n commented Dec 8, 2015

@pathikrit Thanks for the repro. I saved the stacktrace to the gist just in case https://gist.github.com/eed3si9n/c53a4dcc2f3df58d93bd
It's interesting that the commands that are being passed is sbt +clean +coverage +test

@gbougeard

@eed3si9n can you explain why it might be related to coverage or code style plugins?

See #1673

@eed3si9n
Copy link
Member

eed3si9n commented Dec 8, 2015

Is there a specific version of JDK 8 that you guys are using?
I can't reproduce it by running sbt +clean +ivySbt using https://github.com/pathikrit/better-files at 4597e81e9faecc1676c85e7cbc1e5be8506b879a on my Ubuntu machine.

@pathikrit
Copy link

@eed3si9n : If you have a CircleCI, account, you can retry this build yourself with SSH enabled. See: https://circleci.com/gh/pathikrit/better-files/331#ssh-info - it will bring up a VM and rerun for you. If it does not work, let me know, I can give you collab access to that repo.

@sinkovsky
Copy link

Had similar issue, problem was with insufficient disk space on Jenkins volume.
Check that you're not running out of disk space

@pme123
Copy link

pme123 commented Nov 7, 2016

Maybe this helps in finding the problem:
This works:
concurrentRestrictions := Seq( Tags.limit(Tags.CPU, 4), Tags.limit(Tags.Network, 10), Tags.limit(Tags.Test, 1), Tags.limitAll( 15 ) )

This did not work:
concurrentRestrictions in Global := Seq( Tags.limit(Tags.CPU, 4), Tags.limit(Tags.Network, 10), Tags.limit(Tags.Test, 1), Tags.limitAll( 15 ) )

Only difference in Global

@steinybot
Copy link
Contributor

Our build just failed and I was complaining vocally and my team mate just hit the exact same problem on her macbook with a different repository. The only thing we seemed to be doing in common was running sbt with multiple tasks in one go, starting with clean.

@saamalik
Copy link

saamalik commented Dec 20, 2016

Same issue; we've been running our build script 100s of time without issue, and just ran into this. We're unable to reproduce. Our build script starts with a clean

@jk128
Copy link

jk128 commented Feb 8, 2017

Does anyone notice that file that was reported that could not be created is actually there and the contents of this file is exactly the same message - which is very weird? It is something like this:

from the stdout/stderr:

SomeException: "I could not create file somefolder/somefile.txt"

and then we notice file exists so we execute:

$ cat somefolder/somefile.txt

and the result is:

SomeException: "I could not create file somefolder/somefile.txt"

@dwijnand
Copy link
Member

I wonder if all or the strong majority of people hitting this are hitting it due to using sbt-buildinfo and sbt-buildinfo using Extracted.runTask. See sbt/sbt-buildinfo#87 / #2970.

@ghik
Copy link
Author

ghik commented Mar 16, 2017

@dwijnand not in my case - we're not using this plugin

@inkytonik
Copy link

@dwijnand same here. We're seeing the issue but are not using sbt-buildinfo in the relevant project.

@jmooo
Copy link

jmooo commented Mar 30, 2017

We also see this at ~5% rate on our Bamboo builds, using the Play Framework 2.5.9 which builds with; sbt.version=0.13.11. Selecting "retry failed build" usually clears the problem (sometimes have to rebuild a third time, but it always works eventually)

Can't find any pattern to it. Sometimes 10 simultaneous builds work fine. Sometimes 2 of 10 fail. Sometimes a single build is happening with no other activity and fails.

30-Mar-2017 10:48:11	[error] (*:projectDescriptors) Could not create file /var/atlassian/application-data/bamboo/xml-data/build-dir/IVO-TP-JOB1/project/target/streams/$global/projectDescriptors/$global/streams/outjava.io.IOException: No such file or directory

@saamalik
Copy link

saamalik commented Apr 7, 2017

Probably not something you guys want to hear; but even though we ran into it three times in December, since then even though the team size has grown, we never ran into it again. Maybe by adding additional libraries/dependencies we slightly altered the timings of things to where we don't see this.

I hope I didn't jinx the team.

@eed3si9n eed3si9n added this to the 1.0.0-M5 milestone Apr 11, 2017
@eed3si9n eed3si9n changed the title Nondeterministic failure when cleaning project Nondeterministic "No such file or directory" failure when cleaning project Apr 11, 2017
@eed3si9n eed3si9n self-assigned this Apr 11, 2017
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 12, 2017
Fixes sbt#2156

This is a workaround for `clean` and logging clashing when run concurrently on the same subproject.
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 12, 2017
Fixes sbt#2156

cleanFiles is now a task that lists exactly what will be deleted recursively.
It will now exclude target.value / "streams" directory thereby avoiding clash with logging.
To clean the logs and task caches there's now a new task called `cleanBuild`.
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 12, 2017
Fixes sbt#2156

cleanFiles is now a task that lists exactly what will be deleted recursively.
It will now exclude target.value / "streams" directory thereby avoiding clash with logging.
To clean the logs and task caches there's now a new task called `cleanBuild`.
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 13, 2017
Fixes sbt#2156

This is a workaround for `clean` and logging clashing when run concurrently on the same subproject.
@ganeshkaspate
Copy link

ganeshkaspate commented Apr 27, 2017

I am getting this error - Could not create file /target/streams/compile/run/$global/streams/outjava.io.IOException: Too many open files . Is this the same problem ?

@lespea
Copy link

lespea commented Apr 27, 2017

@ganeshkaspate if you're on linux you probably have to bump the file handle limit: https://unix.stackexchange.com/questions/36841/why-is-number-of-open-files-limited-in-linux

@jobtg
Copy link

jobtg commented Jun 27, 2017

We recently started seeing the same issue on a builds using Jenkins on Ubuntu 16.04 & java 1.8.0_131 in both sbt 0.13.13 and 0.13.15. The rate is about 10% of the builds.

Sometimes it's target/streams/$global/ivySbt/$global/streams/outjava.io.IOException: No such file or directory other times it's /streams/$global/ivyConfiguration/$global/streams/outjava.io.IOException: No such file or directory

@ganeshkaspate
Copy link

After debugging , I found that 4096 was limit for my application. So, whenever it reaches to that limit I use to get that error.

@developergakuo
Copy link

developergakuo commented Dec 29, 2017

I get the following error too:
Error:Error while importing SBT project:
...

[error] 	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:76)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:70)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:52)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:37)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:29)
[error] at sbt.StandardMain$.runManaged(Main.scala:104)
[error] at sbt.xMain.run(Main.scala:71)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Could not create directory /home/gakuo/Documents/SA/assignmengts/assignment2/DDDOnionCookExample3/project/target/streams/compile/compileIncSetup/$global/streams: file exists and is not a directory.
[error] Use 'last' for the full log.
Invalid response.

See complete log in file:/home/gakuo/.IdeaIC2017.2/system/log/sbt.last.log

maxheadroom added a commit to ubirch/ubirch-avatar-service that referenced this issue Aug 15, 2018
To fix random SBT build errors as described in:

sbt/sbt#2156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests