quarkusio/quarkus · error · MojoExecutionException
Failed to initialize file output writer
Error message
Failed to initialize file output writer
What it means
DependencyListMojo can write the resolved dependency list to a file (outputFile). Before logging, it creates parent directories and opens a BufferedWriter, applying APPEND when appendOutput is set and the file exists. Any IOException while doing so is wrapped in a MojoExecutionException 'Failed to initialize file output writer', aborting the mojo before any dependency output is produced.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/DependencyListMojo.java:144
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 list to a file", e);
}
};
}
try {
logDependencies(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
- Check and fix filesystem permissions on the output file's parent directory
- Ensure the outputFile path is valid and its parent is a directory, not a file
- Free disk space if the disk is full
- Point -DoutputFile (or pom configuration) to a writable location
Example fix
// before
mvn quarkus:dependency-list -DoutputFile=/root/protected/deps.txt
// after
mvn quarkus:dependency-list -DoutputFile=${project.build.directory}/deps.txt Defensive patterns
Strategy: validation
Validate before calling
// Pre-check output file writability before running the mojo
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);
}
if (java.nio.file.Files.exists(out) && !java.nio.file.Files.isWritable(out)) {
throw new IllegalStateException("Output file not writable: " + out);
} Try / catch
try {
mvn quarkus:dependency-list -DoutputFile=target/deps.txt;
} catch (MojoExecutionException e) {
if ("Failed to initialize file output writer".equals(e.getMessage())) {
// inspect e.getCause() (IOException): fix path/permissions and retry
Throwable cause = e.getCause();
}
} Prevention
- Point output files at ${project.build.directory} which is always writable in a build
- Pre-create output directories in CI before running Maven goals
- Check filesystem permissions when running Maven inside containers
- Monitor disk space in CI environments
When it happens
Trigger: Running mvn quarkus:dependency-list (or related goal) with output file configuration where Files.newBufferedWriter or Files.createDirectories throws IOException — e.g. unwritable path, parent path is a file, or disk/permission problems.
Common situations: outputFile points to a read-only directory or outside the project; parent path exists as a regular file; running in CI with restricted filesystem permissions; container/user mismatch on mounted volumes; 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 log the dependency list to a file
- Failed to initialize file output writer
- 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/1aa668a0e61e3a34.
Report an issue: GitHub.