{"record":{"id":"3741684efee7c02f","repo":"projectlombok/lombok","slug":"delombok-delombok-will-only-write-to-a-directory","errorCode":null,"errorMessage":"DELOMBOK: delombok will only write to a directory. If you want to delombok a single file, use -p to output to standard output, then redirect this to a file:\ndelombok MyJavaFile.java -p >MyJavaFileDelombok.java","messagePattern":"DELOMBOK: delombok will only write to a directory\\. If you want to delombok a single file, use -p to output to standard output, then redirect this to a file:\ndelombok MyJavaFile\\.java -p >MyJavaFileDelombok\\.java","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/delombok/lombok/delombok/Delombok.java","lineNumber":549,"sourceCode":"\t\n\tpublic void setVerbose(boolean verbose) {\n\t\tthis.verbose = verbose;\n\t}\n\t\n\tpublic void setNoCopy(boolean noCopy) {\n\t\tthis.noCopy = noCopy;\n\t}\n\t\n\tpublic void setDisablePreview(boolean disablePreview) {\n\t\tthis.disablePreview = disablePreview;\n\t}\n\t\n\tpublic void setOnlyChanged(boolean onlyChanged) {\n\t\tthis.onlyChanged = onlyChanged;\n\t}\n\t\n\tpublic void setOutput(File dir) {\n\t\tif (dir.isFile() || (!dir.isDirectory() && dir.getName().endsWith(\".java\"))) throw new IllegalArgumentException(\n\t\t\t\t\"DELOMBOK: delombok will only write to a directory. \" +\n\t\t\t\t\"If you want to delombok a single file, use -p to output to standard output, then redirect this to a file:\\n\" +\n\t\t\t\t\"delombok MyJavaFile.java -p >MyJavaFileDelombok.java\");\n\t\toutput = dir;\n\t}\n\t\n\tpublic void setOutputToStandardOut() {\n\t\tthis.output = null;\n\t}\n\t\n\tpublic void setModulepath(String modulepath) {\n\t\tthis.modulepath = modulepath;\n\t}\n\t\n\tpublic void addDirectory(File base) throws IOException {\n\t\taddDirectory0(false, base, \"\", 0);\n\t}\n\t","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/delombok/lombok/delombok/Delombok.java#L531-L567","documentation":"Delombok.setOutput enforces that the output target is a directory: if the given File is an existing file, or a non-existent path whose name ends with '.java', it throws IllegalArgumentException with a hint to use -p for single-file output to stdout. Delombok writes the delomboked tree as a mirror of the source tree and does not support writing a single delomboked .java file directly.","triggerScenarios":"Calling setOutput(new File(\"Foo.java\")) (or CLI -d Foo.java) where Foo.java either exists as a file or does not exist but has a .java extension, or passing any existing file instead of a directory.","commonSituations":"Expecting '-d output.java' to write a single delomboked file; scripting delombok per-file and reusing the CLI switch intended for directory output; build tools wiring a file path into the output option.","solutions":["Pass a directory as the output (-d out/ or setOutput(new File(\"out\"))) and let delombok mirror the source tree","For a single file, run delombok with -p (or no -d) to print to stdout and redirect: delombok MyJavaFile.java -p > MyJavaFileDelombok.java","Rename/remove an accidentally-named .java output path before rerunning"],"exampleFix":"// before\ndelombok MyJavaFile.java -d MyJavaFileDelombok.java\n// after\ndelombok MyJavaFile.java -p > MyJavaFileDelombok.java","handlingStrategy":"validation","validationCode":"File out = new File(outputPath);\nif (out.isFile() || (!out.isDirectory() && out.getName().endsWith(\".java\")))\n    throw new IllegalArgumentException(\"Output must be a directory; use -p > file.java for single-file output\");","typeGuard":null,"tryCatchPattern":"try { delombok.setOutput(out); } catch (IllegalArgumentException e) { System.err.println(e.getMessage()); /* fall back to stdout: use -p */ }","preventionTips":["Always point -d at a directory","For single files, use -p and shell redirection","Never name the output path with a .java suffix"],"tags":["delombok","cli","output-path"],"backgroundTag":"invalid-argument-value","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"}