apache/maven · error · IllegalArgumentException
executable function requires exactly one argument
Error message
executable function requires exactly one argument
What it means
executable() is a built-in function of Maven 4.1 profile activation conditions (<activation><condition>). ConditionFunctions.executable throws IllegalArgumentException unless exactly one string argument (an executable name or path) is supplied; note that a blank name is not an error — it just returns false. The activator converts the arity failure into 'Error parsing profile activation condition' and the profile stays inactive.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java:268
* <pre>
* executable('musl-gcc')
* executable('x86_64-linux-musl-gcc')
* executable('/usr/bin/musl-gcc')
* </pre>
*
* <p>When a plain name (without path separators) is given the function searches every
* directory listed in the {@code PATH} environment variable. On Windows, the platform
* executable extensions ({@code .exe}, {@code .cmd}, {@code .bat}, {@code .com}) are
* tried automatically when the name does not already carry an extension.
*
* @param args A list containing a single string argument: the executable name or path
* @return {@code true} if the executable is found and is a regular, executable file,
* {@code false} otherwise
* @throws IllegalArgumentException if the number of arguments is not exactly one
*/
public Object executable(List<Object> args) {
if (args.size() != 1) {
throw new IllegalArgumentException("executable function requires exactly one argument");
}
String name = ConditionParser.toString(args.get(0));
if (name == null || name.isBlank()) {
return false;
}
return ExecutableFinder.isExecutableInPath(name, context);
}
}
View on GitHub (pinned to e4093d4e12)
Solutions
- Use exactly one argument: executable('docker')
- For several tools combine conditions: executable('docker') and executable('docker-compose')
- Because activation depends on the local PATH, prefer explicit -P profiles in CI for reproducibility
Example fix
<!-- before -->
<condition>executable('docker', true)</condition>
<!-- after -->
<condition>executable('docker')</condition> Defensive patterns
Strategy: validation
Validate before calling
static boolean arityOk(String condition, String fn, int min, int max) {
int i = condition.indexOf(fn + "(");
if (i < 0) return true;
String args = condition.substring(i + fn.length() + 1, condition.indexOf(')', i));
int n = args.isBlank() ? 0 : args.split(",", -1).length;
return n >= min && n <= max;
}
boolean ok = arityOk(condition, "executable", 1, 1); Try / catch
try {
Object r = new ConditionParser(functions, resolver).parse(condition);
} catch (IllegalArgumentException e) {
// report and treat the profile as inactive
} Prevention
- executable takes one name/path; PATH search is automatic, no flag argument
- Remember PATH-dependent activation makes builds machine-dependent — prefer explicit -P in CI
When it happens
Trigger: A condition like executable('docker', true) — there is no second flag; the valid form is executable('docker'), which searches PATH for a plain name or checks the given path directly (Windows extensions .exe/.cmd/.bat/.com are tried automatically).
Common situations: Adding a 'search PATH' boolean out of habit (PATH search is the default behavior); listing several executables as separate arguments instead of combining with 'and'; non-reproducible builds because activation now depends on the machine's PATH, as the Javadoc itself warns.
Related errors
- length function requires exactly one argument
- upper function requires exactly one argument
- lower function requires exactly one argument
- substring function requires 2 or 3 arguments
- indexOf function requires exactly two arguments
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/7b25ca70176b5c49.
Report an issue: GitHub.