{"record":{"id":"4e0476c46a0690dc","repo":"apache/maven","slug":"error-reading-config-file-configfile","errorCode":null,"errorMessage":"Error reading config file: ${configFile}","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":95,"sourceCode":"    }\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());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + configFile, e);\n        }\n    }\n\n    protected MavenOptions parseArgs(String source, List<String> args) throws ParseException {\n        return CommonsCliMavenOptions.parse(source, args.toArray(new String[0]));\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java#L77-L103","documentation":"Maven could not read .mvn/maven.config: Files.lines threw IOException, rethrown as IllegalStateException 'Error reading config file' with the path. The file was confirmed to exist before parsing, so this is an open/read failure: permission denied to the build user, a symlink with a missing target, or an I/O error during the read.","triggerScenarios":"maven.config owned by another user with no read permission (containers running as non-root), a symlink whose target was not checked out, or the file being atomically replaced by an editor exactly while a build starts reading it.","commonSituations":"Docker builds mounting root-owned project directories; CI caches that restore a broken symlink; tooling that rewrites maven.config on every build racing concurrent invocations.","solutions":["`ls -l .mvn/maven.config` - confirm owner and mode allow the build user to read it.","`chmod a+r .mvn/maven.config` or chown it to the build user.","If it is a symlink, make its target exist and be readable.","Commit a static file instead of regenerating it per build; avoid editing it while builds start."],"exampleFix":"# before: root-owned file, CI user cannot read it\n$ ls -l .mvn/maven.config\n-rw------- 1 root root 48 maven.config\n\n# after\n$ chmod a+r .mvn/maven.config\n$ mvn -v","handlingStrategy":"validation","validationCode":"if (Files.exists(configFile) && !Files.isReadable(configFile)) {\n    throw new IllegalStateException(\"maven.config not readable by build user: \" + configFile);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit maven.config with normal read permissions; check `ls -l` when builds fail at startup.","Avoid generating maven.config at build time; use a static committed file."],"tags":["maven","maven-config","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"}