Task Inputs cause FileNotFoundException

Strange exception gets thrown on OSX. The same build works find on Linux. With a quick look it seems that org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter#snapshot doesn’t check if the file exists or is readable before trying to create the hash of it.

org.gradle.api.UncheckedIOException: Failed to capture snapshot of input files for task 'buildDocsHtml' during up-to-date check.  See stacktrace for details.
  at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:59)
  at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:126)
  at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:69)
  at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:52)
  at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
  at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
  at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
  at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:306)
  at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
  at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
  at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
  at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /home/tester/workspace/encodings/__init__.pyc (Permission denied)
  at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:39)
  at org.gradle.api.internal.hash.DefaultHasher.hash(DefaultHasher.java:24)
  at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.snapshot(CachingFileSnapshotter.java:46)
  at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.snapshot(CachingFileSnapshotter.java:27)
  at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$1.run(DefaultFileCollectionSnapshotter.java:56)
  at org.gradle.internal.Factories$1.create(Factories.java:22)
  at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:192)
  at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
  at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
  at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
  at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:60)
  at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter.snapshot(DefaultFileCollectionSnapshotter.java:52)
  at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:55)
  ... 13 more
Caused by: java.io.FileNotFoundException: /home/tester/workspace/encodings/__init__.pyc (Permission denied)
  at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:34)

Is this something new (2.7-rc-1)?

What are the permissions of /home/tester/workspace/encodings/__init__.pyc and are they different between Linux and OSX?

Nope, I saw it happening in 2.3 and 2.6. It’s strange because it only happens on the CI box. I can’t get to the file before the job finishes and deletes the workspace. I’ll see what I can do to get the permissions of the file. I ended up solving the problem by excluding **/*.pyc from task inputs.