{"record":{"id":"e3e8909213cd5745","repo":"Tencent/matrix","slug":"create-directory-outputfile-getabsolutepath","errorCode":null,"errorMessage":"---Create directory '<outputFile.getAbsolutePath()>' failed!","messagePattern":"---Create directory '<outputFile\\.getAbsolutePath\\(\\)>' failed!","errorType":"exception","errorClass":"TaskExecuteException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java","lineNumber":254,"sourceCode":"\n    @Override\n    public TaskResult call() throws TaskExecuteException {\n        ZipFile zipFile = null;\n        try {\n            zipFile = new ZipFile(inputFile);\n            if (outputFile.isDirectory() && outputFile.exists()) {\n                Log.i(TAG, \"%s exists, delete it.\", outputFile.getAbsolutePath());\n                FileUtils.deleteDirectory(outputFile);\n            } else if (outputFile.isFile()) {\n                throw new TaskExecuteException(TAG + \"---File '\" + outputFile.getAbsolutePath() + \"' is already exists!\");\n            }\n            TaskResult taskResult = TaskResultFactory.factory(getType(), TASK_RESULT_TYPE_JSON, config);\n            if (taskResult == null) {\n                return null;\n            }\n            long startTime = System.currentTimeMillis();\n            if (!outputFile.mkdir()) {\n                throw new TaskExecuteException(TAG + \"---Create directory '\" + outputFile.getAbsolutePath() + \"' failed!\");\n            }\n\n            ((TaskJsonResult) taskResult).add(\"total-size\", inputFile.length());\n\n            readMappingTxtFile();\n            config.setProguardClassMap(proguardClassMap);\n            ResguardUtil.readResMappingTxtFile(resMappingTxt, resDirMap, resguardMap);\n            config.setResguardMap(resguardMap);\n\n            Enumeration entries = zipFile.entries();\n            JsonArray jsonArray = new JsonArray();\n            String outEntryName = \"\";\n            while (entries.hasMoreElements()) {\n                ZipEntry entry = (ZipEntry) entries.nextElement();\n                outEntryName = writeEntry(zipFile, entry);\n                if (!Util.isNullOrNil(outEntryName)) {\n                    JsonObject fileItem = new JsonObject();\n                    fileItem.addProperty(\"entry-name\", outEntryName);","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java#L236-L272","documentation":"In UnzipTask.call(), after validating the output path, the task calls outputFile.mkdir(); if directory creation fails it throws TaskExecuteException. mkdir() fails when the parent directory doesn't exist, or the process lacks write permission on the parent.","triggerScenarios":"config.getUnzipPath() has a nonexistent parent directory (mkdir() creates only one level), or the user running the build cannot write to the parent.","commonSituations":"Deep output path whose intermediate directories don't exist; read-only CI workspace; sandboxed/permission-restricted runner; path on a read-only mounted volume.","solutions":["Pre-create parent directories (mkdir -p) or configure a single-level output directory.","Check write permissions on the parent of the configured unzip path and fix them.","Point unzipPath at a writable location inside the project build directory."],"exampleFix":"// before\nconfig.setUnzipPath(\"build/a/b/c/unzip\"); // parents missing\n// after\nnew File(\"build/a/b/c\").mkdirs();\nconfig.setUnzipPath(\"build/a/b/c/unzip\");","handlingStrategy":"try-catch","validationCode":"File out = new File(config.getUnzipPath());\nFile parent = out.getAbsoluteFile().getParentFile();\nif (parent != null) parent.mkdirs();\nif (!parent.canWrite()) {\n    throw new IllegalArgumentException(\"Cannot write to \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.call();\n} catch (TaskExecuteException e) {\n    if (e.getMessage().contains(\"Create directory\")) {\n        throw new GradleException(\"Fix permissions / create parent dirs for unzipPath\", e);\n    }\n    throw e;\n}","preventionTips":["Pre-create parent directories with mkdirs() before running the checker.","Run the build with a user that has write access to the workspace.","Avoid unzip paths on read-only or network volumes."],"tags":["apk-canary","mkdir-failed","permissions","filesystem"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}