{"record":{"id":"7b25ca70176b5c49","repo":"apache/maven","slug":"executable-function-requires-exactly-one-argument","errorCode":null,"errorMessage":"executable function requires exactly one argument","messagePattern":"executable function requires exactly one argument","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java","lineNumber":268,"sourceCode":"     * <pre>\n     *   executable('musl-gcc')\n     *   executable('x86_64-linux-musl-gcc')\n     *   executable('/usr/bin/musl-gcc')\n     * </pre>\n     *\n     * <p>When a plain name (without path separators) is given the function searches every\n     * directory listed in the {@code PATH} environment variable.  On Windows, the platform\n     * executable extensions ({@code .exe}, {@code .cmd}, {@code .bat}, {@code .com}) are\n     * tried automatically when the name does not already carry an extension.\n     *\n     * @param args A list containing a single string argument: the executable name or path\n     * @return {@code true} if the executable is found and is a regular, executable file,\n     *         {@code false} otherwise\n     * @throws IllegalArgumentException if the number of arguments is not exactly one\n     */\n    public Object executable(List<Object> args) {\n        if (args.size() != 1) {\n            throw new IllegalArgumentException(\"executable function requires exactly one argument\");\n        }\n        String name = ConditionParser.toString(args.get(0));\n        if (name == null || name.isBlank()) {\n            return false;\n        }\n        return ExecutableFinder.isExecutableInPath(name, context);\n    }\n}\n","sourceCodeStart":250,"sourceCodeEnd":277,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java#L250-L277","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"<!-- before -->\n<condition>executable('docker', true)</condition>\n\n<!-- after -->\n<condition>executable('docker')</condition>","handlingStrategy":"validation","validationCode":"static boolean arityOk(String condition, String fn, int min, int max) {\n    int i = condition.indexOf(fn + \"(\");\n    if (i < 0) return true;\n    String args = condition.substring(i + fn.length() + 1, condition.indexOf(')', i));\n    int n = args.isBlank() ? 0 : args.split(\",\", -1).length;\n    return n >= min && n <= max;\n}\nboolean ok = arityOk(condition, \"executable\", 1, 1);","typeGuard":null,"tryCatchPattern":"try {\n    Object r = new ConditionParser(functions, resolver).parse(condition);\n} catch (IllegalArgumentException e) {\n    // report and treat the profile as inactive\n}","preventionTips":["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"],"tags":["maven","profile-activation","condition-functions","argument-mismatch","environment"],"backgroundTag":"invalid-function-arguments","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}