{"record":{"id":"fc9953767b264ed3","repo":"ocrmypdf/OCRmyPDF","slug":"sidecar-filename-needed-when-output-file-is-dev","errorCode":null,"errorMessage":"--sidecar filename needed when output file is /dev/null or NUL.","messagePattern":"--sidecar filename needed when output file is /dev/null or NUL\\.","errorType":"validation","errorClass":"BadArgsError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/_validation.py","lineNumber":94,"sourceCode":"            \"Please install the appropriate language data for your OCR engine.\\n\"\n            \"\\n\"\n            \"See the online documentation for instructions:\\n\"\n            \"    https://ocrmypdf.readthedocs.io/en/latest/languages.html\\n\"\n            \"\\n\"\n            \"Note: most languages are identified by a 3-letter ISO 639-2 Code.\\n\"\n            \"For example, English is 'eng', German is 'deu', and Spanish is 'spa'.\\n\"\n            \"Simplified Chinese is 'chi_sim' and Traditional Chinese is 'chi_tra'.\"\n            \"\\n\"\n        )\n        raise MissingDependencyError(msg)\n\n\ndef check_options_sidecar(options: OcrOptions) -> None:\n    if options.sidecar == '\\0':\n        if options.output_file == '-':\n            raise BadArgsError(\"--sidecar filename needed when output file is stdout.\")\n        elif options.output_file == os.devnull:\n            raise BadArgsError(\n                \"--sidecar filename needed when output file is /dev/null or NUL.\"\n            )\n        elif not isinstance(options.output_file, str | Path):\n            # The '\\0' sentinel is only ever set by the CLI, which always\n            # supplies output_file as a plain path - not a stream. If this\n            # somehow fires, the caller mixed a CLI-only sentinel with the\n            # stream-based API.\n            raise BadArgsError(\n                \"--sidecar filename needed when output file is not a path.\"\n            )\n        options.sidecar = os.fspath(options.output_file) + '.txt'\n    if options.sidecar == options.input_file or options.sidecar == options.output_file:\n        raise BadArgsError(\n            \"--sidecar file must be different from the input and output files\"\n        )\n\n\ndef check_options_preprocessing(options: OcrOptions) -> None:","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/_validation.py#L76-L112","documentation":"Same sidecar validation, but for the case where the output file is /dev/null or NUL (Windows). With no real output path, the sidecar filename cannot be auto-derived from it.","triggerScenarios":"options.sidecar == '\\0' and options.output_file equals os.devnull; typically from --output-file /dev/null (or NUL) plus --sidecar with no filename.","commonSituations":"Dry-run/verification runs that discard the PDF but still want the extracted text.","solutions":["Specify an explicit sidecar path: --sidecar text.txt"],"exampleFix":"# before\nocrmypdf --sidecar --output-file /dev/null in.pdf out.pdf\n# after\nocrmypdf --sidecar text.txt --output-file /dev/null in.pdf out.pdf","handlingStrategy":"validation","validationCode":"import os\nif sidecar is None and str(output_file) == os.devnull:\n    sidecar = default_path.with_suffix('.txt')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Dry runs that keep the sidecar need an explicit --sidecar path"],"tags":["ocr","ocrmypdf","sidecar","devnull","cli-arguments"],"backgroundTag":"invalid-option-combination","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}