quarkusio/quarkus · error · IllegalArgumentException
Invalid command line: ${cmdLine}
Error message
Invalid command line: ${cmdLine} What it means
BootstrapMavenOptions.parse(String cmdLine) first translates the raw command line string into arguments using CommandLineUtils.translateCommandline. If the string has unbalanced quotes or otherwise cannot be tokenized (CommandLineException), it throws IllegalArgumentException with the offending command line in the message.
Source
Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java:61
public static final String OFFLINE = "o";
public static final String SUPRESS_SNAPSHOT_UPDATES = "nsu";
public static final String UPDATE_SNAPSHOTS = "U";
public static final String CHECKSUM_FAILURE_POLICY = "C";
public static final String CHECKSUM_WARNING_POLICY = "c";
public static final String BATCH_MODE = "B";
public static final String NO_TRANSFER_PROGRESS = "ntp";
public static final String SYSTEM_PROPERTY = "D";
public static Map<String, Object> parse(String cmdLine) {
if (cmdLine == null) {
return Collections.emptyMap();
}
final String[] args;
try {
args = CommandLineUtils.translateCommandline(cmdLine);
} catch (CommandLineException e) {
throw new IllegalArgumentException("Invalid command line: " + cmdLine, e);
}
if (args.length == 0) {
return Collections.emptyMap();
}
final String mavenHome = PropertyUtils.getProperty("maven.home");
if (mavenHome == null) {
try {
return invokeParser(Thread.currentThread().getContextClassLoader(), args);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Failed to load parser", e);
}
}
final Path mvnLib = Paths.get(mavenHome).resolve("lib");
if (!Files.exists(mvnLib)) {
throw new IllegalStateException("Maven lib dir does not exist: " + mvnLib);View on GitHub (pinned to e1c734241f)
Solutions
- Print the cmdLine from the message and fix unbalanced or mismatched quotes before passing it
- Build the argument list programmatically and join carefully, or avoid embedding quoted -D values (Maven accepts -Dkey=value without quotes when passed as a single arg)
- Pre-test the string with org.codehaus.plexus.util.cli.CommandLineUtils.translateCommandline in a unit test
- Sanitize environment-provided values (MAVEN_OPTS) by trimming or re-quoting them before concatenation
Example fix
// before
BootstrapMavenOptions.newInstance("-Dmaven.repo.local=\"${HOME}/.m2"); // unterminated quote
// after
BootstrapMavenOptions.newInstance("-Dmaven.repo.local=" + repoDir.getAbsolutePath()); Defensive patterns
Strategy: validation
Validate before calling
// Check quotes are balanced before handing the string to the parser
long dq = cmdLine.chars().filter(c -> c == '"').count();
long sq = cmdLine.chars().filter(c -> c == '\'').count();
if (dq % 2 != 0 || sq % 2 != 0) {
throw new IllegalArgumentException("Unbalanced quotes in command line: " + cmdLine);
} Try / catch
try {
BootstrapMavenOptions options = BootstrapMavenOptions.newInstance(cmdLine);
} catch (IllegalArgumentException e) {
log.error("Cannot tokenize command line, fix quoting: " + e.getMessage());
throw e;
} Prevention
- Build command lines from arrays/lists of arguments instead of string concatenation
- Avoid quoting -D values unnecessarily; pass key=value as one token
- Sanitize environment-provided values before embedding them in command strings
- Unit-test the exact command string with CommandLineUtils.translateCommandline
When it happens
Trigger: Calling BootstrapMavenOptions.newInstance(cmdLine) or parse() with a command line string containing unterminated quotes, e.g. -Dkey="value (missing closing quote) or mismatched single/double quotes.
Common situations: Programmatically building MAVEN_OPTS/maven command strings by string concatenation and dropping a quote, copying command lines from shell snippets where quoting semantics differ, env vars (MAVEN_OPTS) with nested quotes set incorrectly.
Related errors
- Failed to parse Maven command line arguments
- Unexpected end of input: ${str}
- unbalanced quotes in
- Failed
- One of type, version or separating them ':' is missing from
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/d3e7d3361ef90a5c.
Report an issue: GitHub.