projectlombok/lombok · error

DELOMBOK: Output file and input file refer to the same…

Error message

DELOMBOK: Output file and input file refer to the same filesystem location. Specify a separate path for output.

What it means

Delombok refuses to run when the input file resolves to the exact same filesystem location as the configured output. `addFile` compares canonical paths of the input base directory and the output directory; if equal, writing delomboked output would overwrite the source, destroying the original files. It throws IOException immediately before queuing the file.

Solutions

  1. Set the output to a different directory than the input, e.g. `-d src-delomboked` or `delombok.setOutput(new File("build/delomboked"))`
  2. Check for symlinks: if input and output are symlinks to the same target, use a real distinct path for one of them
  3. If the goal is in-place delombok, copy sources to a temp directory first, delombok there, then copy back manually

Example fix

// before
delombok.addDirectory(new File("src/main/java"));
delombok.setOutput(new File("src/main/java"));
// after
delombok.addDirectory(new File("src/main/java"));
delombok.setOutput(new File("build/delomboked"));
Defensive patterns

Strategy: validation

Validate before calling

if (out.getCanonicalPath().equals(inBase.getCanonicalPath())) {
    throw new IllegalArgumentException("output must differ from input directory");
}
delombok.setOutput(out);

Try / catch

try { delombok.addDirectory(srcDir); } catch (IOException e) { if (e.getMessage().contains("same filesystem location")) { /* fix output dir */ } throw e; }

Prevention

When it happens

Trigger: Calling `delombok.addFile(base, fileName)` (directly or via `addDirectory`) when the `output` directory was set to the same path as the input base, e.g. `delombok.setOutput(new File("src"))` with `addDirectory(new File("src"))`. Symlinks or `.`/`..` path segments that canonicalize to the same location also trigger it.

Common situations: CI scripts that delombok a source tree in place to inspect generated code; developers pointing `-d` at the same directory as the source root (e.g. `java -jar lombok.jar delombok src -d src`); symlinked directories that look different but resolve to the same path.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07). Data as JSON: /api/errors/e5d0332d6a9abf01. Report an issue: GitHub.

Appendix: source

Thrown at src/delombok/lombok/delombok/Delombok.java:649

			File outFile = new File(output, fileName);
			outFile.getParentFile().mkdirs();
			FileOutputStream out = new FileOutputStream(outFile);
			try {
				while (true) {
					int r = in.read(b);
					if (r == -1) break;
					out.write(b, 0, r);
				}
			} finally {
				out.close();
			}
		} finally {
			in.close();
		}
	}
	
	public void addFile(File base, String fileName) throws IOException {
		if (output != null && canonical(base).equals(canonical(output))) throw new IOException(
				"DELOMBOK: Output file and input file refer to the same filesystem location. Specify a separate path for output.");
		
		File f = new File(base, fileName);
		filesToParse.add(f);
		fileToBase.put(f, base);
	}
	
	public void addPreLombokProcessors(AbstractProcessor processor) {
		preLombokProcessors.add(processor);
	}

	public void addAdditionalAnnotationProcessor(AbstractProcessor processor) {
		additionalAnnotationProcessors.add(processor);
	}
	
	private static <T> com.sun.tools.javac.util.List<T> toJavacList(List<T> list) {
		com.sun.tools.javac.util.List<T> out = com.sun.tools.javac.util.List.nil();
		ListIterator<T> li = list.listIterator(list.size());

View on GitHub (pinned to 6d6a3e9fec)