elastic/elasticsearch · error · IllegalArgumentException

Path does not exist: {path}

Error message

Path does not exist: {path}

What it means

Thrown by JdkJarHellCheck.main (a command-line tool) when one of the path arguments passed on the command line does not exist on the filesystem. The tool scans each argument for JDK jar-hell conditions; a non-existent path is rejected immediately rather than scanned. This is distinct from the runtime JarHell scan and is used to pre-check a distribution.

Source

Thrown at libs/core/src/main/java/org/elasticsearch/jdk/JdkJarHellCheck.java:60

                        detected.add(entry.replace("/", ".").replace(".class", ""));
                    }
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }

    public Set<String> getDetected() {
        return Collections.unmodifiableSet(detected);
    }

    @SuppressForbidden(reason = "command line tool")
    public static void main(String[] argv) throws IOException {
        JdkJarHellCheck checker = new JdkJarHellCheck();
        for (String location : argv) {
            Path path = Paths.get(location);
            if (Files.exists(path) == false) {
                throw new IllegalArgumentException("Path does not exist: " + path);
            }
            checker.scanForJDKJarHell(path);
        }
        if (checker.getDetected().isEmpty()) {
            System.exit(0);
        } else {
            checker.getDetected().forEach(System.out::println);
            System.exit(1);
        }
    }

}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Verify the path exists: 'ls -la <path>' using the same working directory the tool runs from.
  2. Use absolute paths when invoking JdkJarHellCheck to avoid cwd-relative resolution issues.
  3. Ensure the build step that produces the target directory/jar runs before this check.

Example fix

// before
java ... JdkJarHellCheck build/distributions/es lib/modules
// 'Path does not exist: build/distributions/es'

// after: run after the build, with an absolute path
./gradlew assemble
java ... JdkJarHellCheck /abs/path/to/build/distributions/es /abs/path/to/lib/modules
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the CLI, check each arg exists
import java.nio.file.*;

for (String a : argv) {
  if (!Files.exists(Paths.get(a))) throw new IllegalArgumentException(a + " missing");
}

Try / catch

try {
  JdkJarHellCheck.main(args);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Path does not exist")) {
    System.err.println("Fix the path argument: " + e.getMessage());
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking the JdkJarHellCheck CLI with a path argument that Files.exists() reports as false. The loop iterates argv, constructs Paths.get(location), and throws IllegalArgumentException before scanForJDKJarHell.

Common situations: Typo in the path argument; relative path resolved against an unexpected working directory; the target directory was not yet built; CI invoked the tool before artifacts were assembled.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/6428eda8151196e6. Report an issue: GitHub.