quarkusio/quarkus · error · MojoExecutionException

Could not create directory ${outputDirectory}

Error message

Could not create directory ${outputDirectory}

What it means

CreateJBangMojo.execute() first creates the output directory via Files.createDirectories and wraps any IOException into a MojoExecutionException. The message interpolates the configured ${outputDirectory} property. It means the target directory for the generated JBang project could not be created.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateJBangMojo.java:87

    @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
    private RepositorySystemSession repoSession;

    @Parameter(property = "javaVersion")
    private String javaVersion;

    @Component
    private RepositorySystem repoSystem;

    @Component
    RemoteRepositoryManager remoteRepoManager;

    @Override
    public void execute() throws MojoExecutionException {
        try {
            Files.createDirectories(outputDirectory.toPath());
        } catch (IOException e) {
            throw new MojoExecutionException("Could not create directory " + outputDirectory, e);
        }

        File projectRoot = outputDirectory;
        final Path projectDirPath = projectRoot.toPath();

        final MavenArtifactResolver mvn;
        try {
            mvn = MavenArtifactResolver.builder()
                    .setRepositorySystem(repoSystem)
                    .setRepositorySystemSession(
                            getLog().isDebugEnabled() ? repoSession : MojoUtils.muteTransferListener(repoSession))
                    .setRemoteRepositories(repos)
                    .setRemoteRepositoryManager(remoteRepoManager)
                    .build();
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to initialize Maven artifact resolver", e);
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check that -DoutputDirectory is correct and its parent path exists and is writable
  2. Remove/replace any FILE that occupies a segment of the intended directory path
  3. Fix filesystem permissions (chmod/chown) or pick a writable directory
  4. On Windows verify the path has no illegal characters and isn't exceeding MAX_PATH

Example fix

// before
mvn quarkus:create-jbang -DoutputDirectory=/app/out  // /app is read-only
// after
mvn quarkus:create-jbang -DoutputDirectory=$HOME/projects/my-jbang-app
Defensive patterns

Strategy: validation

Validate before calling

java.nio.file.Path out = java.nio.file.Path.of(outputDirectory);
java.nio.file.Path abs = out.toAbsolutePath();
java.nio.file.Path existing = abs;
while (existing != null && !java.nio.file.Files.exists(existing)) existing = existing.getParent();
if (existing == null || !java.nio.file.Files.isDirectory(existing))
    throw new IllegalStateException("A file blocks the path segment: " + existing);
if (!java.nio.file.Files.isWritable(existing))
    throw new IllegalStateException("Not writable: " + existing);

Try / catch

try {
    mvn quarkus:create-jbang -DoutputDirectory=...
} catch (MojoExecutionException e) {
    if (e.getMessage().startsWith("Could not create directory")) {
        logger.error("Cannot create {}: check permissions / file-vs-dir conflict", outputDirectory);
    }
}

Prevention

When it happens

Trigger: Files.createDirectories(outputDirectory.toPath()) throws IOException — parent path is a file, permissions denied, read-only filesystem, or path too long/invalid.

Common situations: -DoutputDirectory pointing inside a read-only mount or container filesystem, a file existing at one of the path segments, permission-restricted corporate machines, typo'd path on Windows (illegal characters).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/6764ed9ad1bb610a. Report an issue: GitHub.