{"record":{"id":"466c43f1d84bb40b","repo":"apache/maven","slug":"error-reading-config-file-atfile","errorCode":null,"errorMessage":"Error reading config file: ${atFile}","messagePattern":"Error reading config file: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java","lineNumber":75,"sourceCode":"\n    protected MavenOptions parseMavenCliOptions(List<String> args) {\n        try {\n            return parseArgs(Options.SOURCE_CLI, args);\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\"Failed to parse CLI arguments: \" + e.getMessage(), e.getCause());\n        }\n    }\n\n    protected MavenOptions parseMavenAtFileOptions(Path atFile) {\n        try (Stream<String> lines = Files.lines(atFile, StandardCharsets.UTF_8)) {\n            List<String> args =\n                    lines.filter(arg -> !arg.isEmpty() && !arg.startsWith(\"#\")).toList();\n            return parseArgs(\"atFile\", args);\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\n                    \"Failed to parse arguments from file (\" + atFile + \"): \" + e.getMessage(), e.getCause());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + atFile, e);\n        }\n    }\n\n    protected MavenOptions parseMavenConfigOptions(Path configFile) {\n        try (Stream<String> lines = Files.lines(configFile, StandardCharsets.UTF_8)) {\n            List<String> args =\n                    lines.filter(arg -> !arg.isEmpty() && !arg.startsWith(\"#\")).toList();\n            MavenOptions options = parseArgs(\"maven.config\", args);\n            if (options.goals().isPresent()) {\n                // This file can only contain options, not args (goals or phases)\n                throw new IllegalArgumentException(\"Unrecognized entries in maven.config (\" + configFile + \") file: \"\n                        + options.goals().get());\n            }\n            return options;\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\n                    \"Failed to parse arguments from maven.config file (\" + configFile + \"): \" + e.getMessage(),\n                    e.getCause());","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java#L57-L93","documentation":"While reading the `@argfile` given on the mvn command line, Files.lines threw an IOException, rethrown as IllegalStateException 'Error reading config file' with the path. The file could not be opened or read as UTF-8: it is missing, a directory, permission-denied, a dangling symlink, or hit an I/O error mid-read. Parsing never started - this is a filesystem-level failure.","triggerScenarios":"`mvn @/path/that/does/not/exist`, an @file with mode bits that deny read to the build user, the path resolving to a directory, or the file being replaced/deleted while Maven reads it.","commonSituations":"Relative @file paths resolved from a different CI working directory; files created by root with a restrictive umask inside containers; symlinks whose targets are not checked out.","solutions":["Verify the path printed in the message: `ls -l <atFile>`.","Use an absolute path, or resolve the relative path against the directory mvn runs from.","Fix permissions (`chmod a+r`) or ownership so the build user can read the file.","Make sure the path is a regular file, not a directory or broken symlink."],"exampleFix":"# before: run from a directory other than the project root\nmvn @build.args   # build.args lives in the project root\n\n# after: absolute path\nmvn @/checkout/myproject/build.args","handlingStrategy":"validation","validationCode":"if (!Files.isReadable(atFile) || !Files.isRegularFile(atFile)) {\n    throw new IllegalArgumentException(\"@argfile missing or unreadable: \" + atFile);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute @argfile paths in CI.","Ensure build user read permission on shared argfiles.","Avoid swapping argfile contents while builds are starting."],"tags":["maven","cli","argfile","file-io","permissions"],"backgroundTag":"config-file-unreadable","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}