{"record":{"id":"74433de653926166","repo":"arduino/Arduino","slug":"can-t-extract-file-outputfile-file-already-exis","errorCode":null,"errorMessage":"Can't extract file {outputFile}, file already exists!","messagePattern":"Can't extract file (.+?), file already exists!","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/utils/ArchiveExtractor.java","lineNumber":215,"sourceCode":"          // 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);\n          hardLinksMode.put(outputFile, mode);\n        } else if (isSymLink) {\n          symLinks.put(outputFile, linkName);\n          symLinksModifiedTimes.put(outputFile, modifiedTime);\n        } else {\n          // Create the containing folder if not exists\n          if (!outputFile.getParentFile().isDirectory()) {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java#L197-L233","documentation":"When an archive entry is a regular file (or link/symlink) and a file already exists at the destination path while overwrite is false, extract() throws this IOException. It protects existing files from being silently replaced during library installation.","triggerScenarios":"extract() into a destination folder that already contains a file with the same relative path as an archive entry, with the overwrite flag false (default).","commonSituations":"Reinstalling the same library version over an existing installation; Library Manager update flow racing with a manually installed copy; retrying a failed extraction that partially completed without overwrite enabled.","solutions":["Call extract with overwrite=true when intentional replacement (upgrade/reinstall) is desired","Remove the existing library folder from libraries/ (or the destination) before extracting","Catch this IOException and prompt the user whether to overwrite, then retry with overwrite enabled"],"exampleFix":"// before\ntry {\n  archiveExtractor.extract(archive, dest, 1); // throws if files exist\n} catch (IOException e) { /* install aborts */ }\n// after\narchiveExtractor.extract(archive, dest, 1, true); // explicit overwrite on reinstall","handlingStrategy":"try-catch","validationCode":"// check for existing files at archive entry paths before extracting\nif (destFolder.exists()) {\n  try (TarArchiveInputStream in = new TarArchiveInputStream(new FileInputStream(archiveFile))) {\n    TarArchiveEntry e;\n    while ((e = in.getNextTarEntry()) != null) {\n      if (!e.isDirectory() && new File(destFolder, e.getName()).exists()) throw new IllegalStateException(\"Already installed: \" + e.getName());\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try { extractor.extract(archive, dest, 1); } catch (IOException e) { if (e.getMessage().startsWith(\"Can't extract file\")) { boolean ok = askUserToOverwrite(); if (ok) extractor.extract(archive, dest, 1, true); } else { throw e; } }","preventionTips":["Remove the old library folder before reinstalling","Use overwrite=true for deliberate upgrades","Serialize installs so concurrent extractions cannot collide"],"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"}