flxzt/rnote · error
Either "--output-file" or "--output-format" is required.
Error message
Either "--output-file" or "--output-format" is required.
What it means
Doc export needs to know the target format, which must come from either --output-file or --output-format. clap marks one of them required; this (None, None) arm is the defensive fallback in create_doc_export_prefs_from_args that fires if neither is present despite the parse-time requirement.
Solutions
- Add --output-format <svg|xopp|pdf> to the doc export command.
- Or provide --output-file <path> with a supported extension.
- If calling the function from code, ensure at least one of the two options is set.
Example fix
// before rnote export doc notes.rnote // after rnote export doc notes.rnote --output-format pdf
Defensive patterns
Strategy: validation
Validate before calling
case "$ARGS" in *--output-file*|*--output-format*) ;; *) echo "doc export needs --output-file or --output-format"; exit 2;; esac
Prevention
- Always supply --output-format (or --output-file) for doc export.
- Check the subcommand's --help for required options.
- Fail fast in scripts when required flags are missing.
When it happens
Trigger: Invoking doc export with neither --output-file nor --output-format. Normally rejected by clap; reachable only if the required constraint is removed or the prefs function is called directly with both None.
Common situations: Scripts building the command dynamically and dropping both flags; direct calls to create_doc_export_prefs_from_args from other code with unset options.
Understand the failure class
Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.
Related errors
- There must be at least one rnote file specified for…
- Failed to get filename from the supplied file
- The option "--file-stem" cannot be used when exporting…
- Expected only a single rnote file. The option…
- The output file " " needs to have a supported extension to…
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/662ab0ff43e7187d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-cli/src/export.rs:307
(Some(file), None) => match file.as_ref().extension().and_then(|ext| ext.to_str()) {
Some(extension) => doc_export_format_from_ext_str(extension)?,
None => {
return Err(anyhow::anyhow!(
"The output file \"{}\" needs to have a supported extension to determine its file type.",
file.as_ref().display()
));
}
},
(None, Some(out_format)) => out_format,
// should be unreachable because the arguments are exclusive (clap conflicts_with)
(Some(_), Some(_)) => {
return Err(anyhow::anyhow!(
"\"--output-file\" and \"--output-format\" are mutually exclusive."
));
}
// should be unreachable because either --output-file or --output-format is required
(None, None) => {
return Err(anyhow::anyhow!(
"Either \"--output-file\" or \"--output-format\" is required."
));
}
};
let prefs = DocExportPrefs {
export_format: format,
with_background: !no_background,
with_pattern: !no_pattern,
optimize_printing,
page_order,
};
Ok(prefs)
}
fn doc_export_format_from_ext_str(format: &str) -> anyhow::Result<DocExportFormat> {
match format {View on GitHub (pinned to bbc5354502)