projectlombok/lombok · error · InvalidCommandLineException
Cannot obtain canonical path to dependency
Error message
Cannot obtain canonical path to dependency
What it means
Same tool as above: while converting each dependency path from the classpath into a canonical path to decide if it lives under the lombok tree, a failing getCanonicalPath() throws InvalidCommandLineException naming the offending dependency file.
Solutions
- Check the file named in the message exists and is readable
- Remove stale entries from the classpath argument
- Rebuild/refresh dependencies so jars referenced actually exist
- Inspect the wrapped IOException cause for details
Example fix
// before java ... conf.cp=/old/path/lib.jar // after java ... conf.cp=/valid/path/lib.jar
Defensive patterns
Strategy: validation
Validate before calling
for (String f : classpath.split(File.pathSeparator)) {
if (!new File(f).exists()) throw new IllegalStateException("classpath entry missing: " + f);
} Try / catch
try { tool.go(); } catch (InvalidCommandLineException e) { if (e.getMessage().startsWith("Cannot obtain canonical path to dependency")) { fixStaleEntry(e.getMessage()); } throw e; } Prevention
- Prune stale jars from classpath arguments
- Rebuild dependencies so referenced artifacts exist
- Replace broken symlinks in the local repository
When it happens
Trigger: A dependency path listed in the '-cp'-derived argument doesn't exist, is unreadable, or canonicalization fails (broken symlink, removed file).
Common situations: Stale classpath entries pointing at deleted jars, broken symlinks in the local repo, running with a corrupted dependency list.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Cannot obtain canonical path to parent directory
- I/O problem during delombok
- ${element} ${message}
- I/O exception uploading
- I/O issue reading creds file
AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07).
Data as JSON: /api/errors/88fe1536347c514a.
Report an issue: GitHub.
Appendix: source
Thrown at src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java:109
self = new File("..").getCanonicalPath();
} catch (IOException e) {
throw new InvalidCommandLineException("Cannot obtain canonical path to parent directory", e);
}
String bootpath = getBootPath();
launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/bin/main" path="3" type="2"/> \"/>\n");
for (Map.Entry<String, String> entry : args.entrySet()) {
if (!entry.getKey().startsWith("conf.")) continue;
String v = entry.getValue();
if (v.equals("NONE")) continue;
String[] files = v.split(Pattern.quote(File.pathSeparator));
for (String file : files) {
String n;
try {
n = new File(file).getCanonicalPath();
} catch (IOException e) {
throw new InvalidCommandLineException("Cannot obtain canonical path to dependency " + file, e);
}
if (n.startsWith(self)) {
launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="");
launchContent.append(n.substring(self.length()));
launchContent.append("" path="3" type="2"/> \"/>\n");
}
}
}
if (bootpath != null) launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/" + bootpath + "" path="5" type="2"/> \"/>\n");
launchContent.append("\t</listAttribute>\n");
}
private void epilogue() throws InvalidCommandLineException {
String type = getArgString("testType");
launchContent.append("\t<booleanAttribute key=\"org.eclipse.jdt.launching.DEFAULT_CLASSPATH\" value=\"false\"/>\n");
String jvmTarget = getArgString("jvmTarget");
String bootpath = getBootPath();View on GitHub (pinned to 6d6a3e9fec)