flxzt/rnote · error

Open file for path failed

Error message

Open file for path {:?} failed

What it means

TryFrom conversion error in SplitOrder::try_from::<u32>: the numeric value (typically deserialized from persisted file data) is not a valid SplitOrder discriminant (RowMajor/ColumnMajor), so no valid split order exists for it. Indicates corrupt or out-of-range stored data.

Solutions

  1. Verify the file '<resource_path>/<sound_name>.<ending>' exists and is readable (ls -l)
  2. Reinstall rnote or restore the bundled sound assets in the app data directory
  3. Check spelling/case of the sound name and its extension; fix permissions with chmod if needed

Example fix

// before
player.load_sound_from_path("pen-sound", "ogg", missing_dir)
// after
let dir = PathBuf::from("/usr/share/rnote/sounds"); // ensure assets exist here
assert!(dir.join("pen-sound.ogg").exists());
player.load_sound_from_path("pen-sound", "ogg", dir)
Defensive patterns

Strategy: try-catch

Validate before calling

let path = resource_dir.join(format!("{}.{}", sound_name, ending));
if !path.is_file() {
    eprintln!("sound asset missing: {}", path.display());
}

Type guard

fn sound_asset_exists(dir: &Path, name: &str, ending: &str) -> bool {
    dir.join(format!("{}.{}", name, ending)).is_file()
}

Try / catch

match load_result {
    Err(e) if e.to_string().contains("Open file for path") => {
        log::warn!("sound asset missing or unreadable; disabling audio feedback");
        // continue without sound instead of failing init
    }
    other => other,
}

Prevention

When it happens

Trigger: Initializing the audio player with a sound whose file 'name.ending' does not exist under the resource path, or the process lacks read permission for it.

Common situations: Broken installation with missing sound assets; custom sound packs with wrong file names/extensions; relocating the app data directory without the sounds; restrictive file permissions.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at crates/rnote-engine/src/audioplayer.rs:208

            _ => {
                sink.append(self.sounds["typewriter_thump"].clone());
                sink.detach();
            }
        }
    }
}

fn load_sound_from_path(
    mut resource_path: PathBuf,
    sound_name: &str,
    ending: &str,
) -> anyhow::Result<Buffered<Decoder<File>>> {
    resource_path.push(format!("{sound_name}.{ending}"));

    if resource_path.exists() {
        let buffered =
            rodio::Decoder::new(File::open(resource_path.clone()).with_context(|| {
                anyhow::anyhow!("Open file for path {:?} failed", resource_path,)
            })?)?
            .buffered();

        // initialize the buffer
        buffered.clone().for_each(|_| {});

        Ok(buffered)
    } else {
        Err(anyhow::anyhow!(
            "Failed to init audioplayer. file `{resource_path:?}` does not exist."
        ))
    }
}

View on GitHub (pinned to bbc5354502)