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

  1. Check the file named in the message exists and is readable
  2. Remove stale entries from the classpath argument
  3. Rebuild/refresh dependencies so jars referenced actually exist
  4. 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

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


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=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/bin/main&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;\"/>\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=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;");
					launchContent.append(n.substring(self.length()));
					launchContent.append("&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;\"/>\n");
				}
			}
		}
		if (bootpath != null) launchContent.append("\t\t<listEntry value=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/" + bootpath + "&quot; path=&quot;5&quot; type=&quot;2&quot;/&gt;&#10;\"/>\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)