quarkusio/quarkus · error · QuarkusUpdateException

Cannot locate mvnw or mvn. Make sure mvnw is in the project

Error message

Cannot locate mvnw or mvn. Make sure mvnw is in the project directory or mvn is in your PATH.

What it means

findMvnBinary(baseDir) uses findWrapperOrBinary(baseDir, "mvnw", "mvn") to locate the Maven wrapper script in the project or an `mvn` executable on the PATH (adding .cmd/.bat on Windows). If neither is found, it throws QuarkusUpdateException telling the user to put mvnw in the project directory or mvn on the PATH, because the Maven-based OpenRewrite update needs to launch Maven.

Source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateCommand.java:285

                } finally {
                    log.info("");
                }
            }
        } catch (Exception e) {
            throw new QuarkusUpdateException("The %s command exited with an error. %s".formatted(name, logInfo), e);
        }
    }

    private static List<String> prepareCommand(List<String> command) {
        final List<String> effectiveCommand = new ArrayList<>(command);
        propagateSystemPropertyIfSet("maven.repo.local", effectiveCommand);
        return effectiveCommand;
    }

    static String findMvnBinary(Path baseDir) {
        Path mavenCmd = findWrapperOrBinary(baseDir, "mvnw", "mvn");
        if (mavenCmd == null) {
            throw new QuarkusUpdateException("Cannot locate mvnw or mvn"
                    + ". Make sure mvnw is in the project directory or mvn is in your PATH.");
        }
        return mavenCmd.toString();
    }

    static String findGradleBinary(Path baseDir) {
        Path gradleCmd = findWrapperOrBinary(baseDir, "gradlew", "gradle");
        if (gradleCmd == null) {
            throw new QuarkusUpdateException("Cannot gradlew mvnw or gradle"
                    + ". Make sure gradlew is in the current directory or gradle in your PATH.");
        }
        return gradleCmd.toString();
    }

    private static Path findWrapperOrBinary(Path baseDir, String wrapper, String cmd) {
        Path found = searchPath(wrapper, baseDir.toString());
        if (found == null) {
            found = searchPath(cmd);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Install Maven and make sure `mvn -v` works in the same shell used to run the Quarkus update command.
  2. Or add the Maven wrapper to the project (run `mvn wrapper:wrapper` once, or copy mvnw/mvnw.cmd plus .mvn/wrapper from a Maven project) so it is committed to the repository.
  3. Verify the PATH contains the Maven bin directory (restart the terminal/CI job after PATH changes).
  4. In CI, use a Maven-provisioned base image or setup step (e.g. setup-maven/actions) before running `quarkus update`.

Example fix

// before
$ quarkus update
QuarkusUpdateException: Cannot locate mvnw or mvn. Make sure mvnw is in the project directory or mvn is in your PATH.

// after: add the wrapper and commit it
$ mvn wrapper:wrapper
$ ls mvnw .mvn/wrapper/maven-wrapper.properties
$ quarkus update
Defensive patterns

Strategy: validation

Validate before calling

import java.io.IOException;
import java.nio.file.*;

static void requireMavenAvailable(Path baseDir) {
    boolean wrapper = Files.isRegularFile(baseDir.resolve("mvnw"))
            || Files.isRegularFile(baseDir.resolve("mvnw.cmd"));
    boolean onPath = false;
    try {
        onPath = new ProcessBuilder("mvn", "-v").start().waitFor() == 0;
    } catch (IOException | InterruptedException ignored) { }
    if (!wrapper && !onPath) {
        throw new IllegalStateException("mvnw must be in the project directory or mvn on the PATH");
    }
}

Type guard

static boolean isMavenAvailable(Path baseDir) {
    if (Files.isRegularFile(baseDir.resolve("mvnw"))
            || Files.isRegularFile(baseDir.resolve("mvnw.cmd"))) return true;
    try {
        return new ProcessBuilder("mvn", "-v").start().waitFor() == 0;
    } catch (Exception e) {
        return false;
    }
}

Try / catch

try {
    QuarkusUpdateCommand.handle(log, BuildTool.MAVEN, baseDir, rewritePluginVersion, recipesGAV, recipe, logFile, dryRun);
} catch (QuarkusUpdateException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Cannot locate mvnw or mvn")) {
        log.error("Install Maven or add the wrapper: `mvn wrapper:wrapper`, then retry `quarkus update`.");
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: QuarkusUpdateCommand.handle() -> runMavenUpdate() on a MAVEN build tool project where: no mvnw/mvnw.cmd exists in baseDir (or its parents) AND no `mvn` binary is resolvable from the PATH environment variable.

Common situations: Clean CI containers with no Maven installed and no committed wrapper; freshly cloned projects where the wrapper scripts were excluded by .gitignore; Windows environments where mvn is installed but not on the PATH of the shell running the Quarkus CLI; IDE terminals with a minimal environment.

Related errors


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