{"record":{"id":"57b5e71f0e10df68","repo":"elastic/elasticsearch","slug":"can-t-write-resource-resourcepath-to-destin","errorCode":null,"errorMessage":"Can't write resource `${resourcePath}` to ${destination}","messagePattern":"Can't write resource `(.+?)` to (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ExportElasticsearchBuildResourcesTask.java","lineNumber":113,"sourceCode":"\n    @TaskAction\n    public void doExport() {\n        if (resources.isEmpty()) {\n            setDidWork(false);\n            throw new StopExecutionException();\n        }\n        resources.entrySet().stream().parallel().forEach(entry -> {\n            String resourcePath = entry.getKey();\n            String destName = entry.getValue();\n            Path destination = outputDir.get().file(destName).getAsFile().toPath();\n            try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) {\n                Files.createDirectories(destination.getParent());\n                if (is == null) {\n                    throw new GradleException(\"Can't export `\" + resourcePath + \"` from build-tools: not found\");\n                }\n                Files.copy(is, destination, StandardCopyOption.REPLACE_EXISTING);\n            } catch (IOException e) {\n                throw new GradleException(\"Can't write resource `\" + resourcePath + \"` to \" + destination, e);\n            }\n        });\n    }\n\n}\n","sourceCodeStart":95,"sourceCodeEnd":119,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ExportElasticsearchBuildResourcesTask.java#L95-L119","documentation":"Thrown by ExportElasticsearchBuildResourcesTask.doExport when Files.copy of the resource stream to the destination fails with IOException. The resource was found on the classpath but writing it to outputDir/<destName> failed.","triggerScenarios":"The destination directory is read-only, the disk is full, the parent cannot be created, or the destination is locked by another process when Files.copy runs.","commonSituations":"Output directory on a read-only mount; disk exhaustion; antivirus/file lock on Windows; permission denied on the build output tree.","solutions":["Check write permissions and free disk space on the output directory.","Ensure the output directory is not on a read-only filesystem.","Close any process locking the destination file (IDE, antivirus, prior build).","Point Gradle's build output to a writable location."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Path dest = outputDir.get().file(destName).getAsFile().toPath();\nif (Files.isWritable(dest.getParent()) == false) {\n    throw new GradleException(\"Output directory not writable: \" + dest.getParent());\n}","typeGuard":null,"tryCatchPattern":"try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) {\n    Files.copy(is, destination, StandardCopyOption.REPLACE_EXISTING);\n} catch (IOException e) {\n    throw new GradleException(\"Can't write resource `\" + resourcePath + \"` to \" + destination, e);\n}","preventionTips":["Ensure the build output directory is writable and has free space.","Close IDEs/antivirus that may lock destination files on Windows.","Clean stale outputs before exporting resources."],"tags":["gradle","io","resources","build-tools"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}