Skip to content
Latchkey

Maven "mvn: command not found" in CI - Install or PATH Maven

The shell could not find the mvn binary. Either Maven is not installed on the runner, or it is installed but its bin directory is not on PATH.

What this error means

The build step fails instantly with mvn: command not found (or mvn: not found) before any Maven output. Nothing about the POM is reached.

shell
+ mvn -B clean verify
/usr/bin/env: bash: line 1: mvn: command not found
##[error]Process completed with exit code 127.

Common causes

Maven not installed on the runner

A minimal base image or container ships a JDK but not Maven. The mvn launcher simply does not exist.

Maven installed but not on PATH

Maven is unpacked somewhere under /opt, but its bin directory was never added to PATH, so the shell cannot resolve mvn.

How to fix it

Use the Maven Wrapper so no global install is needed

Commit the wrapper and call ./mvnw; it downloads the pinned Maven version on demand.

Terminal
mvn -N wrapper:wrapper -Dmaven=3.9.9   # generate mvnw once, commit it
./mvnw -B clean verify                 # CI uses the wrapper

Install Maven on the runner

Install the package or unpack the distribution and put its bin on PATH.

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y maven
mvn -version

How to prevent it

  • Prefer the committed Maven Wrapper (./mvnw) so every runner uses the same pinned Maven without a global install or PATH tweak.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →