{"record":{"id":"e5d0332d6a9abf01","repo":"projectlombok/lombok","slug":"delombok-output-file-and-input-file-refer-to-the","errorCode":null,"errorMessage":"DELOMBOK: Output file and input file refer to the same filesystem location. Specify a separate path for output.","messagePattern":"DELOMBOK: Output file and input file refer to the same filesystem location\\. Specify a separate path for output\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/delombok/lombok/delombok/Delombok.java","lineNumber":649,"sourceCode":"\t\t\tFile outFile = new File(output, fileName);\n\t\t\toutFile.getParentFile().mkdirs();\n\t\t\tFileOutputStream out = new FileOutputStream(outFile);\n\t\t\ttry {\n\t\t\t\twhile (true) {\n\t\t\t\t\tint r = in.read(b);\n\t\t\t\t\tif (r == -1) break;\n\t\t\t\t\tout.write(b, 0, r);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tout.close();\n\t\t\t}\n\t\t} finally {\n\t\t\tin.close();\n\t\t}\n\t}\n\t\n\tpublic void addFile(File base, String fileName) throws IOException {\n\t\tif (output != null && canonical(base).equals(canonical(output))) throw new IOException(\n\t\t\t\t\"DELOMBOK: Output file and input file refer to the same filesystem location. Specify a separate path for output.\");\n\t\t\n\t\tFile f = new File(base, fileName);\n\t\tfilesToParse.add(f);\n\t\tfileToBase.put(f, base);\n\t}\n\t\n\tpublic void addPreLombokProcessors(AbstractProcessor processor) {\n\t\tpreLombokProcessors.add(processor);\n\t}\n\n\tpublic void addAdditionalAnnotationProcessor(AbstractProcessor processor) {\n\t\tadditionalAnnotationProcessors.add(processor);\n\t}\n\t\n\tprivate static <T> com.sun.tools.javac.util.List<T> toJavacList(List<T> list) {\n\t\tcom.sun.tools.javac.util.List<T> out = com.sun.tools.javac.util.List.nil();\n\t\tListIterator<T> li = list.listIterator(list.size());","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/delombok/lombok/delombok/Delombok.java#L631-L667","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the output to a different directory than the input, e.g. `-d src-delomboked` or `delombok.setOutput(new File(\"build/delomboked\"))`","Check for symlinks: if input and output are symlinks to the same target, use a real distinct path for one of them","If the goal is in-place delombok, copy sources to a temp directory first, delombok there, then copy back manually"],"exampleFix":"// before\ndelombok.addDirectory(new File(\"src/main/java\"));\ndelombok.setOutput(new File(\"src/main/java\"));\n// after\ndelombok.addDirectory(new File(\"src/main/java\"));\ndelombok.setOutput(new File(\"build/delomboked\"));","handlingStrategy":"validation","validationCode":"if (out.getCanonicalPath().equals(inBase.getCanonicalPath())) {\n    throw new IllegalArgumentException(\"output must differ from input directory\");\n}\ndelombok.setOutput(out);","typeGuard":null,"tryCatchPattern":"try { delombok.addDirectory(srcDir); } catch (IOException e) { if (e.getMessage().contains(\"same filesystem location\")) { /* fix output dir */ } throw e; }","preventionTips":["Always delombok into a separate build directory (e.g. build/delomboked)","Canonicalize paths before configuring output to catch symlinks","Never configure in-place delombok in CI scripts"],"tags":["io","filesystem","delombok","input-output-overlap"],"backgroundTag":"file-already-exists","analyzedSha":"6d6a3e9fec0a9555702561fbeb8eac836575116e","analyzedAt":"2026-09-07T23:18:01.841Z","contentChangedAt":"2026-09-07T23:18:01.841Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}