{"record":{"id":"e2136314b9f99f00","repo":"elastic/elasticsearch","slug":"failed-to-copy-to","errorCode":null,"errorMessage":"Failed to copy {} to {}","messagePattern":"Failed to copy (.+?) to (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":1339,"sourceCode":"     * @param destinationRoot destination to link to\n     */\n    private void syncWithLinks(Path sourceRoot, Path destinationRoot) {\n        sync(sourceRoot, destinationRoot, (Path d, Path s) -> {\n            try {\n                Files.createLink(d, s);\n            } catch (IOException e) {\n                // Note does not work for network drives, e.g. Vagrant\n                throw new LinkCreationException(\"Failed to create hard link \" + d + \" pointing to \" + s, e);\n            }\n        });\n    }\n\n    private void syncWithCopy(Path sourceRoot, Path destinationRoot) {\n        sync(sourceRoot, destinationRoot, (Path d, Path s) -> {\n            try {\n                Files.copy(s, d);\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to copy \" + s + \" to \" + d, e);\n            }\n        });\n    }\n\n    private void sync(Path sourceRoot, Path destinationRoot, BiConsumer<Path, Path> syncMethod) {\n        assert Files.exists(destinationRoot) == false;\n        try {\n            Files.walkFileTree(sourceRoot, new SimpleFileVisitor<>() {\n                @Override\n                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {\n                    Path relativeDestination = sourceRoot.relativize(dir);\n                    if (relativeDestination.getNameCount() <= 1) {\n                        return FileVisitResult.CONTINUE;\n                    }\n                    // Throw away the first name as the archives have everything in a single top level folder we are not interested in\n                    relativeDestination = relativeDestination.subpath(1, relativeDestination.getNameCount());\n                    Path destination = destinationRoot.resolve(relativeDestination);\n                    Files.createDirectories(destination);","sourceCodeStart":1321,"sourceCodeEnd":1357,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L1321-L1357","documentation":"Thrown by syncWithCopy — the copy-based fallback used when hard-linking is not desired. Files.copy(s, d) failed with IOException. This path is the more permissive sibling of syncWithLinks and is used when the sync method is selected as copy rather than link.","triggerScenarios":"Files.copy throws when the destination's parent does not exist, the source vanished mid-walk, disk is full, or a permission/security manager denied the write. Happens inside the sync() walker for each file under sourceRoot.","commonSituations":"Disk full under the build dir; an antivirus/EDR blocked the write; the source tree changed during the walk (a concurrent process deleted a file between walkFileTree enumeration and the copy); running on a read-only or quota-limited filesystem.","solutions":["Free space on the volume holding the testclusters working dir and check disk quota.","Disable/reconfigure antivirus that may block writes into the gradle build directory.","Ensure no other gradle daemon or test is concurrently mutating the same sourceRoot.","Inspect the wrapped IOException for the specific OS error and address that."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Files.copy(s, d);\n} catch (IOException e) {\n    throw new UncheckedIOException(\"Failed to copy \" + s + \" to \" + d, e);\n}","preventionTips":["Ensure free disk space and quota on the testclusters volume.","Exclude the build dir from antivirus that may block writes.","Do not run two cluster teardowns against the same sourceRoot concurrently."],"tags":["testclusters","copy","io","disk-full"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}