{"record":{"id":"309cf95b5f133159","repo":"arduino/Arduino","slug":"can-t-create-folder-outputfile-a-file-with-the","errorCode":null,"errorMessage":"Can't create folder {outputFile}, a file with the same name exists!","messagePattern":"Can't create folder (.+?), a file with the same name exists!","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/utils/ArchiveExtractor.java","lineNumber":208,"sourceCode":"          if (!linkName.startsWith(pathPrefix)) {\n            throw new IOException(\"Invalid archive: it must contain a single root folder while file \" + linkName + \" is outside \" + pathPrefix);\n          }\n          linkName = linkName.substring(pathPrefix.length());\n          outputLinkedFile = new File(destFolder, linkName);\n        }\n        if (isSymLink) {\n          // Symbolic links are referenced with relative paths\n          outputLinkedFile = new File(linkName);\n          if (outputLinkedFile.isAbsolute()) {\n            System.err.println(I18n.format(tr(\"Warning: file {0} links to an absolute path {1}\"), outputFile, outputLinkedFile));\n            System.err.println();\n          }\n        }\n\n        // Safety check\n        if (isDirectory) {\n          if (outputFile.isFile() && !overwrite) {\n            throw new IOException(\"Can't create folder \" + outputFile + \", a file with the same name exists!\");\n          }\n        } else {\n          // - isLink\n          // - isSymLink\n          // - anything else\n          if (outputFile.exists() && !overwrite) {\n            throw new IOException(\"Can't extract file \" + outputFile + \", file already exists!\");\n          }\n        }\n\n        // Extract the entry\n        if (isDirectory) {\n          if (!outputFile.exists() && !outputFile.mkdirs()) {\n            throw new IOException(\"Could not create folder: \" + outputFile);\n          }\n          foldersTimestamps.put(outputFile, modifiedTime);\n        } else if (isLink) {\n          hardLinks.put(outputFile, outputLinkedFile);","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java#L190-L226","documentation":"During extraction, when an entry is a directory, extract() checks whether a regular file already exists at the destination path. If it does and overwrite is false, it throws this IOException rather than clobbering or failing mid-write. This is a safety check so extraction never silently replaces a file with a folder.","triggerScenarios":"extract(file, dest, stripPath, overwrite=false) where the destination already contains a file whose name collides with a directory entry in the archive (e.g. an old partial install left a file where the archive has a folder).","commonSituations":"Reinstalling/upgrading a library into a destination where a previous layout used files at paths now occupied by directories; leftover temp/lock files colliding with archive directory names; installing into a non-empty destination folder.","solutions":["Delete the conflicting file (or clear the destination folder) and extract again","Call extract with overwrite=true to replace existing files/directories","Manually inspect the destination for stray files with the same names as the archive's folders and resolve the conflict"],"exampleFix":"// before\nnew ArchiveExtractor().extract(archive, destFolder, 1); // overwrite defaults to false\n// after\nnew ArchiveExtractor().extract(archive, destFolder, 1, true); // allow replacing stale entries","handlingStrategy":"try-catch","validationCode":"// detect file-vs-folder conflicts before extracting\nif (destFolder.exists()) {\n  Files.walk(destFolder.toPath()).filter(Files::isRegularFile).map(p -> p.getFileName().toString())\n    .filter(n -> expectedArchiveDirNames.contains(n)).forEach(n -> { throw new IllegalStateException(\"Conflict: file \" + n + \" blocks archive folder\"); });\n}","typeGuard":null,"tryCatchPattern":"try { extractor.extract(archive, dest, 1); } catch (IOException e) { if (e.getMessage().startsWith(\"Can't create folder\")) { clearDestination(dest); extractor.extract(archive, dest, 1, true); } else { throw e; } }","preventionTips":["Extract into a clean destination folder","Pass overwrite=true on reinstall/upgrade flows","Clean up partially completed extractions before retrying"],"tags":["filesystem","conflict","overwrite","arduino"],"backgroundTag":"file-already-exists","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}