flxzt/rnote · error

Failed to get filename from the supplied file

Error message

Failed to get filename from the supplied file '{}'

What it means

run_create builds a fresh empty rnote document and saves it to the path supplied on the command line. Before saving it extracts the file name component via Path::file_name(); if the path has no file name component (e.g. it terminates in '..' or is the filesystem root), there is no name to embed in the document, so it aborts with this error. The '{}' in the message is a template placeholder; the actual path is interpolated via rnote_file.display().

Solutions

  1. Pass a concrete file path with a real file name, e.g. `rnote create notes.rnote` instead of a directory or '..' path.
  2. Normalize the path in the shell before invoking (e.g. use realpath/dirname) so it terminates in a file name.
  3. In code, guard with Path::file_name().is_some() before calling run_create and surface a clearer message.

Example fix

// before
rnote create foo/..
// after
rnote create foo/notes.rnote
Defensive patterns

Strategy: validation

Validate before calling

let path = std::path::Path::new(arg);
if path.file_name().is_none() {
    eprintln!("'{}' does not name a file (no filename component)", arg);
    std::process::exit(2);
}

Type guard

fn has_file_name(p: &std::path::Path) -> bool { p.file_name().is_some() }

Prevention

When it happens

Trigger: Calling `rnote create <path>` where <path> has no file_name(): a path ending in a trailing component like '.' or '..' (e.g. `rnote create ..` or `rnote create foo/..`), or the root path `/`. Also any odd path (e.g. from shell expansion) that normalizes to a non-file component.

Common situations: Shell scripts building paths with string concatenation that end in '/' or '..'; users typo-ing the target as a directory instead of a file; running in a root-like directory where '.' resolves to the filesystem root.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/fe98472166cc98a4. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-cli/src/create.rs:12

// Imports
use crate::cli;
use rnote_engine::Engine;
use std::path::Path;

pub(crate) async fn run_create(rnote_file: &Path) -> anyhow::Result<()> {
    let engine = Engine::default();
    let Some(rnote_file_name) = rnote_file
        .file_name()
        .map(|s| s.to_string_lossy().to_string())
    else {
        return Err(anyhow::anyhow!(
            "Failed to get filename from the supplied file '{}'",
            rnote_file.display()
        ));
    };
    let rnote_bytes = engine.save_as_rnote_bytes(rnote_file_name).await??;
    cli::create_overwrite_file_w_bytes(rnote_file, &rnote_bytes).await?;
    Ok(())
}

View on GitHub (pinned to bbc5354502)