{"record":{"id":"dfbbd1a5b0eb9cc2","repo":"quarkusio/quarkus","slug":"failed-to-log-the-dependency-tree-to-a-file","errorCode":null,"errorMessage":"Failed to log the dependency tree to a file","messagePattern":"Failed to log the dependency tree to a file","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/DependencyTreeMojo.java","lineNumber":118,"sourceCode":"        if (outputFile == null) {\n            log = s -> getLog().info(s);\n        } else {\n            final BufferedWriter bw;\n            try {\n                Files.createDirectories(outputFile.toPath().getParent());\n                final OpenOption[] openOptions = appendOutput && outputFile.exists()\n                        ? new OpenOption[] { StandardOpenOption.APPEND }\n                        : new OpenOption[0];\n                bw = writer = Files.newBufferedWriter(outputFile.toPath(), openOptions);\n            } catch (IOException e) {\n                throw new MojoExecutionException(\"Failed to initialize file output writer\", e);\n            }\n            log = s -> {\n                try {\n                    bw.write(s);\n                    bw.newLine();\n                } catch (IOException e) {\n                    throw new RuntimeException(\"Failed to log the dependency tree to a file\", e);\n                }\n            };\n        }\n        try {\n            logTree(log);\n        } finally {\n            if (writer != null) {\n                try {\n                    writer.close();\n                } catch (IOException e) {\n                    getLog().debug(\"Failed to close the output file\", e);\n                }\n            }\n        }\n    }\n\n    private void logTree(final Consumer<String> log) throws MojoExecutionException {\n        log.accept(\"Quarkus application \" + mode.toUpperCase() + \" mode build dependency tree:\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/DependencyTreeMojo.java#L100-L136","documentation":"DependencyTreeMojo writes the dependency tree output through a consumer lambda that wraps a BufferedWriter. If writing a line to the target file throws an IOException, the lambda wraps it in a RuntimeException with this message. The goal was asked to write the tree to a file but the file could not be written.","triggerScenarios":"Running `mvn quarkus:dependency-tree` where the log consumer writes to a file whose path is unwritable, the parent directory does not exist, the file is locked by another process, or the disk is full.","commonSituations":"Output file placed in a read-only directory; parent directory not created; another process (tail, editor, previous crashed build) holds a lock on the file; full disk on CI; Windows file handle still open from a prior run.","solutions":["Check that the directory containing the output file exists and is writable (create it with mkdir -p / chmod).","Close any process holding the output file open, or choose a different output file path.","Free disk space if the filesystem is full.","Run the goal from a directory where the current user has write permissions instead of a system location."],"exampleFix":"// before\nmvn quarkus:dependency-tree -DoutputFile=/proc/out.txt\n// after\nmkdir -p target/reports && mvn quarkus:dependency-tree -DoutputFile=target/reports/deptree.txt","handlingStrategy":"validation","validationCode":"// before running: ensure output location is writable\nPath out = Path.of(\"target/deptree.txt\");\nFiles.createDirectories(out.getParent());\nif (!Files.isWritable(out.getParent())) throw new IllegalStateException(\"Output dir not writable: \" + out.getParent());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write tool output under target/ or another known-writable directory.","Ensure the parent directory exists before running the goal.","Avoid holding the output file open in other processes during builds.","Monitor CI agents for full disks."],"tags":["maven","io","file-write","quarkus"],"backgroundTag":"file-write-permission-denied","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}