Error releasing lock on artifact cache: java.io.IOException: Bad file descriptor

After upgrade from 0.9.2 to 1.0-milestone-6 or 1.0-milestone-7 All that I get from gradle clean build is list of “Bad file descriptor” errors kind of:

Error releasing lock on artifact cache (/Users/mike/.gradle/caches/artifacts-7): java.io.IOException: Bad file descriptor

I tried to removing build and caches directory, but nothing helps. Any hint how to cure this?

The build.gradle is as simple as:

apply plugin: ‘java’

repositories {

mavenCentral() }

error is reproducible even with just: gradle clean

Error releasing lock on no_buildscript class cache for build file ‘/Users/…/build.gradle’ (/Users/…/.gradle/caches/1.0-milestone-7/scripts/build_5b4bcjsm6obmf8t02fk6ks22vv/ProjectScript/no_buildscript): java.io.IOException: Bad file descriptor

gradle -version:

Gradle 1.0-milestone-7 Gradle build time: Thursday, January 5, 2012 10:24:43 AM UTC Groovy: 1.8.4 Ant: Apache Ant™ version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_03-p3 (Sun Microsystems Inc. 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00) OS: Darwin 9.8.0 i386

Could it be that my JVM (http://landonf.bikemonkey.org/static/soylatte/) somehow become compatible with recent 1.0 milestones?

I do find some issue with cache locking e.g. GRADLE-1801 but they don’t exactly match my problem I believe (and they are fixed in 1.0-m7).

There is also stack trace that I get only for some runs (inconsistently):

:compileJava

FAILURE: Build aborted because of an internal error.

  • What went wrong: Build aborted because of an unexpected internal error. Please file an issue at: http://www.gradle.org.

  • Try: Run with --debug option to get additional debug info.

  • Exception is: java.nio.channels.OverlappingFileLockException

at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1173)

at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1075)

at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:881)

at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lockRegion(DefaultFileLockManager.java:287)

at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lockStateRegion(DefaultFileLockManager.java:278)

at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:207)

at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.(DefaultFileLockManager.java:98)

at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:68)

at org.gradle.cache.internal.DefaultCacheAccess.getLock(DefaultCacheAccess.java:274)

at org.gradle.cache.internal.DefaultCacheAccess.access$100(DefaultCacheAccess.java:39)

at org.gradle.cache.internal.DefaultCacheAccess$UnitOfWorkFileAccess.writeToFile(DefaultCacheAccess.java:285)

at org.gradle.cache.internal.MultiProcessSafePersistentIndexedCache.getCache(MultiProcessSafePersistentIndexedCache.java:84)

at org.gradle.cache.internal.MultiProcessSafePersistentIndexedCache.get(MultiProcessSafePersistentIndexedCache.java:35)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.gradle.listener.LazyCreationProxy$LazyInvocationHandler.invoke(LazyCreationProxy.java:49)

at $Proxy19.get(Unknown Source)

at org.gradle.api.internal.changedetection.CacheBackedTaskHistoryRepository.loadHistory(CacheBackedTaskHistoryRepository.java:89)

at org.gradle.api.internal.changedetection.CacheBackedTaskHistoryRepository.getHistory(CacheBackedTaskHistoryRepository.java:43)

at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository.getStateFor(DefaultTaskArtifactStateRepository.java:48)

at org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactStateRepository.getStateFor(ShortCircuitTaskArtifactStateRepository.java:38)

at org.gradle.api.internal.changedetection.FileCacheBroadcastTaskArtifactStateRepository.getStateFor(FileCacheBroadcastTaskArtifactStateRepository.java:31)

at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:42)

at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)

at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)

at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)

at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)

at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)

at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)

at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)

at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)

at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)

at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)

at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)

at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)

at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)

at org.gradle.cache.internal.DefaultCacheAccess$1.create(DefaultCacheAccess.java:111)

at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:126)

at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:109)

at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:103)

at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)

at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)

at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)

at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)

at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:152)

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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

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)

BUILD FAILED

Do you have a stack trace for the ‘error releasing lock’ problem? You can run gradle with -s to get the stack trace.

Also, could you try your build with the Apple JVM, or a recent openjdk 7 build?

Unfortunately openjdk 7 requires 64 bit system, I have 32 only, so I can run Java 6 only using soylatte JVM.

I tried running gradle with Apple JVM v5 and it indeed worked. So as long as gradle works with Java 5 it should be good workaround. Although I need specifically set that gradle have to use Apple JVM v5 instead of Java 6 default one.

So currently before running gradle I just need:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home

Please let me know if you know other way to make it default choice for gradle. As I install gradle from port

sudo port install gradle-devel I can of course edit directly the script

/opt/local/share/java/gradle/bin/gradle and set JAVA_HOME in it.

It would be nice to have some .gradlerc to set it there externally.

Thanks for help/pointers anyway. I haven’t thought it could be jvm-gradle compatibility issue. Not sure if you need to fix this regression and use of soylatte jvm is probably very rare but there is no other Java 6 choice on 32 bit Intel macs for now. And good that there is workaround to use Apple JVM v5.