{"record":{"id":"1fa227cd55b763c3","repo":"arduino/Arduino","slug":"could-not-create-folder-outputfile","errorCode":null,"errorMessage":"Could not create folder: {outputFile}","messagePattern":"Could not create folder: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/utils/ArchiveExtractor.java","lineNumber":222,"sourceCode":"\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()) {\n            outputFile.getParentFile().mkdirs();\n          }\n          copyStreamToFile(in, size, outputFile);\n          outputFile.setLastModified(modifiedTime);\n        }\n\n        // Set file/folder permission","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java#L204-L240","documentation":"ArchiveExtractor throws this IOException while unzipping an archive when a directory entry cannot be created on disk: the target File neither exists nor can be created via mkdirs(). It typically indicates a filesystem-level problem (permissions, existing non-directory file at that path, disk full, or illegal path characters).","triggerScenarios":"extract() processes a zip/tar entry with isDirectory==true, outputFile does not yet exist, and File.mkdirs() returns false (parent dirs not creatable, permission denied, path segment occupied by a regular file, or name too long/invalid).","commonSituations":"Extracting a library or platform archive into an Arduino data directory with wrong ownership; a previous partial extraction left a file where a directory should be; extracting on a case-insensitive filesystem where entry names collide; read-only volume or full disk.","solutions":["Check that the parent directory of the extraction target exists, is writable by the current user, and contains no regular file with the same name as an archive directory entry","Clear the stale/partial extraction directory and re-extract (rm -rf the target, then retry)","Run with sufficient privileges or fix ownership (chown/chmod) of the destination folder","Verify disk free space and that the path length/characters are valid for the OS filesystem"],"exampleFix":"// before: extract into a path that may be blocked\nextractor.extract(archive, new File(\"/usr/share/arduino/libraries/MyLib\"));\n// after: ensure a clean writable target\ndir.mkdirs();\nif (!dir.isDirectory() || !dir.canWrite()) throw new IllegalStateException(\"bad target\");\nextractor.extract(archive, dir);","handlingStrategy":"try-catch","validationCode":"File target = new File(destDir, entryName);\nif (target.exists() && !target.isDirectory())\n  throw new IllegalStateException(\"File blocks directory entry: \" + target);\nif (!destDir.canWrite()) throw new IllegalStateException(\"Dest not writable: \" + destDir);","typeGuard":"static boolean isExtractableDir(File f) {\n  return !f.exists() || (f.isDirectory() && f.canWrite());\n}","tryCatchPattern":"try {\n  extractor.extract(archive, dir);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Could not create folder\")) {\n    // clean stale target and retry\n    FileUtils.deleteQuietly(dir); dir.mkdirs(); extractor.extract(archive, dir);\n  } else throw e;\n}","preventionTips":["Pre-clean the extraction target directory before every install","Verify write permission on the destination before extracting","Never name files the same as sibling directory entries in your archives","Check free disk space before large extractions"],"tags":["filesystem","io","archive-extraction","mkdir"],"backgroundTag":"mkdir-permission-denied","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"}