Gradle fails with "No such file or directory" when trying to create tmp dir in cache (since M5)

This seems to only happen with one of my builds, but I have not been able to pinpoint what part of the setup is different from other builds. The last part of the stacktrace looks like this:

Caused by: java.io.IOException: No such file or directory
 at org.gradle.api.internal.artifacts.ivyservice.TempFileResolutionCacheManager.tmpFile(TempFileResolutionCacheManager.java:63)

I have looked at the code and it seems like something is deleting the ‘tmp’ directory this class creates under the cache directory before this tmpFile(…) method is called.

This looks like a bug in TempFileResolutionCacheManager. It will be fixed in M6.

My guess is that you’re deleting the entire cache at some point in your build: it would be interesting to see the stacktrace lines leading up to the one you provided to provide more clues.

Didn’t even know it was possible to delete the cache from the build. Should it be??

The only thing in my build that is a little different, and actually where it fails, is this task below that checks that no duplicate dependencies are present in the build. It fails on the line with resolvedArtifacts.each:

task deps {
    x = [:] as Map
    gradle.taskGraph.whenReady {
        def found = gradle.taskGraph.allTasks.find {
            it.path.endsWith(":dependencies")
        }
          if (!found) {
            project.allprojects {
                it.configurations.all {
                    it.resolvedConfiguration.resolvedArtifacts.each { a ->
                        it = a.resolvedDependency
                        y = x.get("${it.moduleGroup}:${it.moduleName}")
                          if (y == null) {
                            y = new HashSet()
                            x.put("${it.moduleGroup}:${it.moduleName}", y)
                        }
                          y.add("${it.moduleVersion}")
                    }
                }
            }
            result = x.groupBy {it.value.size() > 1}
            def duplicates = result.get(true)
            if (duplicates != null) {
                throw new IllegalStateException("Dependencies with several versions: " + duplicates)
            }
        }
      }
}

I have looked at the latest version of TempFileResolutionCacheManager and saw you made a comment in the commit about whether the fix was required or not. Well, now you know :wink:

Did not find a way to attach a file, so here is the full stacktrace:

* Exception is:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':masterdata-common:compile'.
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:47)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:26)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$BrokenResolvedConfiguration.getResolvedArtifacts(ErrorHandlingArtifactDependencyResolver.java:143)
 at build_528nt2ir7lri6jl9t3facpiq64$_run_closure1_closure7_closure9_closure11.doCall(/Users/gits/dev/nos/code/nosmd/build.gradle:15)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:112)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
 at org.gradle.api.internal.DefaultDomainObjectCollection$1.execute(DefaultDomainObjectCollection.java:190)
 at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:144)
 at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:149)
 at org.gradle.api.DomainObjectCollection$all.call(Unknown Source)
 at build_528nt2ir7lri6jl9t3facpiq64$_run_closure1_closure7_closure9.doCall(/Users/gits/dev/nos/code/nosmd/build.gradle:14)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:112)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
 at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:861)
 at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:866)
 at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:853)
 at org.gradle.api.Project$allprojects.call(Unknown Source)
 at build_528nt2ir7lri6jl9t3facpiq64$_run_closure1_closure7.doCall(/Users/gits/dev/nos/code/nosmd/build.gradle:13)
 at org.gradle.messaging.dispatch.BroadcastDispatch$ClosureInvocationHandler.dispatch(BroadcastDispatch.java:119)
 at org.gradle.messaging.dispatch.BroadcastDispatch$ClosureInvocationHandler.dispatch(BroadcastDispatch.java:104)
 at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)
 at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:32)
 at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:75)
 at $Proxy3.graphPopulated(Unknown Source)
 at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:80)
 at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
 at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)
 at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)
 at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
 at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:45)
 at org.gradle.launcher.exec.DefaultGradleLauncherActionExecuter.execute(DefaultGradleLauncherActionExecuter.java:49)
 at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:41)
 at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:84)
 at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:82)
 at org.gradle.util.Swapper.swap(Swapper.java:38)
 at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:82)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:45)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:48)
 at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.HandleSleep.execute(HandleSleep.java:35)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.ReportExceptions.execute(ReportExceptions.java:36)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.ForwardOutput.execute(ForwardOutput.java:46)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:32)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.UpdateDaemonStateAndHandleBusyDaemon.execute(UpdateDaemonStateAndHandleBusyDaemon.java:33)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:34)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:34)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.HandleClientDisconnectBeforeSendingCommand.execute(HandleClientDisconnectBeforeSendingCommand.java:21)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.StopConnectionAfterExecution.execute(StopConnectionAfterExecution.java:21)
 at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:116)
 at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:47)
 at org.gradle.launcher.daemon.server.Daemon$1$1.run(Daemon.java:98)
 at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: No such file or directory
 at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyResolver.resolve(DefaultIvyDependencyResolver.java:72)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.call(CacheLockingArtifactDependencyResolver.java:37)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.call(CacheLockingArtifactDependencyResolver.java:35)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.withCacheLock(DefaultCacheLockingManager.java:51)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:35)
 at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:42)
 at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyResolver.java:78)
 at org.gradle.api.internal.artifacts.ivyservice.EventBroadcastingArtifactDependencyResolver.resolve(EventBroadcastingArtifactDependencyResolver.java:37)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:36)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:232)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
 at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:86)
 at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:51)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getProperty(Unknown Source)
 ... 70 more
Caused by: java.lang.RuntimeException: java.io.IOException: No such file or directory
 at org.gradle.api.internal.artifacts.ivyservice.TempFileResolutionCacheManager.tmpFile(TempFileResolutionCacheManager.java:67)
 at org.gradle.api.internal.artifacts.ivyservice.TempFileResolutionCacheManager.getResolvedIvyFileInCache(TempFileResolutionCacheManager.java:41)
 at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:246)
 at org.apache.ivy.Ivy.resolve(Ivy.java:512)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyResolver.resolve(DefaultIvyDependencyResolver.java:69)
 ... 83 more
Caused by: java.io.IOException: No such file or directory
 at org.gradle.api.internal.artifacts.ivyservice.TempFileResolutionCacheManager.tmpFile(TempFileResolutionCacheManager.java:63)
 ... 87 more

I tried to build with the latest snapshot (1.0-milestone-6-20111108000050) which includes the fix you mentioned, and it worked without any problems :slight_smile:

Glad it worked for you. The comment I attached to the commit is actually referring to the fact that we may not need the TempFileResolutionCacheManager at all, not that the fix may not have been required.

Aha :slight_smile: