[GRADLE-1801] Could not open cache directory ... taskArtifacts Created: 20/Sep/11  Updated: 04/Jan/13  Resolved: 07/Dec/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-4
Fix Version/s: 1.0-milestone-7

Type: Bug
Reporter: Basile Chandesris Assignee: Unassigned
Resolution: Fixed Votes: 9

Attachments: Zip Archive minimal.zip    
Issue Links:
Duplicate
Duplicates GRADLE-2020 Locked cache directory Resolved

 Description   

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not open cache directory /z/foo/workspace/PRJJ/.gradle/1.0-milestone-5-20110913092800+0200/taskArtifacts.
    Cause: Timeout waiting to lock cache directory /z/foo/workspace/PRJJ/.gradle/1.0-milestone-5-20110913092800+0200/taskArtifacts. It is currently in use by another Gradle instance.

===
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'jetty'
apply plugin: 'project-report'

repositories

{ mavenCentral() mavenRepo urls: "https://repository.apache.org/content/groups/staging" mavenRepo urls: "https://repository.jboss.org/nexus/content/repositories/releases/" mavenRepo urls: "http://m2repo.spockframework.org/snapshots/" mavenRepo urls: "http://nexus.devlab722.net/nexus/content/repositories/snapshots" mavenRepo urls: "http://nexus.devlab722.net/nexus/content/repositories/releases" }

hibernateVersion = '3.6.7.Final'
h2Version = '1.3.159'
tapestryVersion = '5.3-beta-9'
sl4jVersion = '1.6.2'

configurations

{ all*.exclude group:'commons-logging', module: 'commons-logging' all*.exclude group:'log4j', module: 'log4j' all*.exclude group:'org.slf4j', module: 'slf4j-log4j12' all*.exclude group: 'cglib', module: 'cglib' }

dependencies

{ //groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.1' groovy localGroovy() providedCompile 'javax.servlet:servlet-api:2.5' // consolidate logging to use slf4 api and logback as implementation // Note ordering of dependencies to ensure logback initialized properly as early as possible compile 'ch.qos.logback:logback-core:0.9.29', 'ch.qos.logback:logback-classic:0.9.29', 'org.slf4j:jcl-over-slf4j:'+sl4jVersion, 'org.slf4j:jul-to-slf4j:'+sl4jVersion, 'org.javassist:javassist:3.15.0-GA', 'org.apache.commons:commons-lang3:3.0.1', 'org.hibernate:hibernate-validator:4.2.0.Final', 'org.hibernate:hibernate-core:'+hibernateVersion, 'com.h2database:h2:'+h2Version, 'org.apache.tapestry:tapestry-hibernate:'+tapestryVersion, 'org.apache.tapestry:tapestry-core:'+tapestryVersion, 'org.apache.tapestry:tapestry-ioc:'+tapestryVersion, 'org.apache.tapestry:tapestry-beanvalidator:'+tapestryVersion testCompile 'junit:junit:4.8.2', // 'org.spockframework:spock-core:0.6-groovy-1.8-SNAPSHOT', // 'org.spockframework:spock-spring:0.6-groovy-1.8-SNAPSHOT', // tapestry-test 'org.testng:testng:5.13.1', 'org.easymock:easymock:2.4' }

task run(dependsOn:'jettyRun') <<{
ant.java(classname: 'foo.StartBrowser', fork: false,
classpath: "${sourceSets.main.runtimeClasspath.asPath}")
}

jettyRun

{ httpPort = 8080 }

 Comments   
Comment by Basile Chandesris [ 20/Sep/11 ]

Caused by: org.gradle.cache.internal.LockTimeoutException: Timeout waiting to lock cache directory /z/foo/workspace/PRJJ/.gradle/1.0-milestone-5-20110913092800+0200/taskArtifacts. It is currently in use by another Gradle instance.
at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:156)
at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.<init>(DefaultFileLockManager.java:53)
at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:34)
at org.gradle.cache.internal.DefaultPersistentDirectoryCache.init(DefaultPersistentDirectoryCache.java:54)
... 38 more

Comment by Chris Birchall [ 07/Nov/11 ]

I've also run into this problem with 1.0-milestone-5 on Windows.

I have a multi-project setup, with the following task in my master project's build.gradle:

subprojects {
task run(type: JavaExec)

{ main = 'com.mycompany.Main' classpath = project.sourceSets.main.runtimeClasspath systemProperties = ['foo': project.name, 'bar': project.projectDir] args = ['abc', 'def'] }

}

Trying to run multiple instances of this task simultaneously results in the error given in the description above.

Haven't found any workaround so far.

Comment by Rolf Suurd [ 29/Dec/11 ]

When trying to run a concurrent build i still get a lock timeout, in my buildSrc folder:

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not open cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc).
    Cause: Timeout waiting to lock cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc). It is currently in use by another Gradle instance.
    Owner PID: 4300
    Our PID: 4712
    Owner Operation:
    Our operation:
    Lock file: D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc\cache.properties.lock

I used gradle-1.0-milestone-7-20111228012857+0100

Comment by Adam Murdoch [ 31/Dec/11 ]

@rolf, do you have a stacktrace for this failure? You can run gradle with the -s option to get the stack trace. I suspect it's a different problem (with the same symptom).

Comment by Rolf Suurd [ 02/Jan/12 ]

Hello Adam, here is the console output with --stacktrace:

FAILURE: Build failed with an exception.

* What went wrong:
Could not open cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc).
Cause: Timeout waiting to lock cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc). It is currently in use by another Gradle instance.
Owner PID: 6648
Our PID: 5420
Owner Operation:
Our operation:
Lock file: D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc\cache.properties.lock

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.cache.CacheOpenException: Could not open cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc).
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:53)
        at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.doOpenDir(DefaultCacheFactory.java:62)
        at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.openStateCache(DefaultCacheFactory.java:105)
        at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:226)
        at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:219)
        at org.gradle.cache.internal.DefaultCacheRepository$AbstractCacheBuilder.open(DefaultCacheRepository.java:113)
        at org.gradle.initialization.BuildSourceBuilder.createBuildSourceClasspath(BuildSourceBuilder.java:86)
        at org.gradle.initialization.BuildSourceBuilder.buildAndCreateClassLoader(BuildSourceBuilder.java:57)
        at org.gradle.initialization.SettingsHandler.findSettingsAndLoadIfAppropriate(SettingsHandler.java:84)
        at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:46)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:76)
        at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
        at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
        at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
        at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
        at org.gradle.launcher.Main.doAction(Main.java:48)
        at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
        at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
        at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
        at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
        at org.gradle.launcher.Main.main(Main.java:39)
        at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
        at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: org.gradle.cache.internal.LockTimeoutException: Timeout waiting to lock cache directory buildSrc (D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc). It is currently in use by another Gradle instance.
Owner PID: 6648
Our PID: 5420
Owner Operation:
Our operation:
Lock file: D:\prg\projects\hydra\buildSrc\.gradle\noVersion\buildSrc\cache.properties.lock
        at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:232)
        at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.<init>(DefaultFileLockManager.java:98)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:68)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:56)
        at org.gradle.cache.internal.DefaultCacheAccess.open(DefaultCacheAccess.java:75)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:45)
        ... 27 more


BUILD FAILED

Total time: 1 mins 0.999 secs
Comment by Rolf Suurd [ 05/Jan/12 ]

I have attached a zip file with a project containing a (empty) buildSrc folder, which reproduces my problem (Obviously my own project has actual build logic in there ).

Running gradle jettyRun, and then running gradle jettyStop in another terminal results in the stacktrace i posted above.

I really hope that with the release of milestone 7 (great work!) this current issue (which still occurs with the released milestone 7) won't be forgotten. It prevents me from upgrading from milestone 3, which i really want to

Should i perhaps file a new issue, because, as Adam suggested above, it's a different problem with the same characteristics?

(edited for typos)

Comment by Adam Murdoch [ 05/Jan/12 ]

@rolf, could you open a new issue, please?

Comment by Simon McClenahan [ 17/May/12 ]

I have worked around the issue by deleting the buildSrc directory.

Generated at Wed Jun 30 12:04:43 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.