quarkusio/quarkus · error · MojoExecutionException
Failed to initialize file output writer
Error message
Failed to initialize file output writer
What it means
DependencyTreeMojo writes the dependency tree to outputFile when configured. It creates parent directories and opens a BufferedWriter (with APPEND if appendOutput and the file exists); any IOException is wrapped in a MojoExecutionException 'Failed to initialize file output writer', aborting before the tree is rendered.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/DependencyTreeMojo.java:111
protected MavenArtifactResolver resolver;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
BufferedWriter writer = null;
final Consumer<String> log;
if (outputFile == null) {
log = s -> getLog().info(s);
} else {
final BufferedWriter bw;
try {
Files.createDirectories(outputFile.toPath().getParent());
final OpenOption[] openOptions = appendOutput && outputFile.exists()
? new OpenOption[] { StandardOpenOption.APPEND }
: new OpenOption[0];
bw = writer = Files.newBufferedWriter(outputFile.toPath(), openOptions);
} catch (IOException e) {
throw new MojoExecutionException("Failed to initialize file output writer", e);
}
log = s -> {
try {
bw.write(s);
bw.newLine();
} catch (IOException e) {
throw new RuntimeException("Failed to log the dependency tree to a file", e);
}
};
}
try {
logTree(log);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
getLog().debug("Failed to close the output file", e);View on GitHub (pinned to e1c734241f)
Solutions
- Fix permissions on the target directory or choose a writable outputFile path
- Ensure the parent path is a directory (or removable so it can be created)
- Check disk space
- Default to console output (omit outputFile) if file output is not essential
Example fix
// before
mvn quarkus:dependency-tree -DoutputFile=/etc/deptree.txt
// after
mvn quarkus:dependency-tree -DoutputFile=${project.build.directory}/deptree.txt Defensive patterns
Strategy: validation
Validate before calling
// Pre-check output file writability before running the goal
java.nio.file.Path out = java.nio.file.Path.of(outputFile);
java.nio.file.Path parent = out.toAbsolutePath().getParent();
if (parent == null || !java.nio.file.Files.isDirectory(parent) && !parent.toFile().mkdirs()) {
throw new IllegalStateException("Cannot create directory: " + parent);
}
if (!java.nio.file.Files.isWritable(parent)) {
throw new IllegalStateException("Directory not writable: " + parent);
} Try / catch
try {
mvn quarkus:dependency-tree -DoutputFile=target/tree.txt;
} catch (MojoExecutionException e) {
if ("Failed to initialize file output writer".equals(e.getMessage())) {
// check e.getCause() (IOException): permissions/path/disk, fix and retry
}
} Prevention
- Write tree output under ${project.build.directory}, never system paths
- Ensure parent directories exist and are writable before CI runs
- Avoid system/read-only locations when running in containers
- Keep adequate free disk space on build agents
When it happens
Trigger: Running quarkus:dependency-tree with an output file target that cannot be opened — permission denied, parent path is a file, invalid path, or underlying filesystem I/O error.
Common situations: Read-only CI workspaces; outputFile inside a non-existent non-creatable location; parent directory existing as a file; volume mount permission issues in containers; disk full.
Understand the failure class
Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.
Related errors
- Failed to initialize file output writer
- Failed to log the dependency list to a file
- Failed to log the dependency tree to a file
- Unable to write quarkus native image agent caller filter to
- Failed to create the output dir ${projectFile}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ebe974fe89f7ef93.
Report an issue: GitHub.