Pumpkin-MC/Pumpkin · error · PlayerDataError

IO error

Error message

IO error: {0}

What it means

Variant `Io` of `PlayerDataError` in pumpkin-world's player data storage. It is automatically converted (`#[from]`) from `std::io::Error`. The library throws it when file operations for player save data fail — creating directories, reading, or writing the player's NBT data file.

Solutions

  1. Check the wrapped io::Error message and fix the underlying filesystem issue (permissions, disk space)
  2. Ensure the playerdata directory exists and is writable by the server process
  3. Verify the world data path configured for `PlayerDataStorage::new` is correct

Example fix

// before: assuming playerdata dir exists
let path = data_path.join(format!("{}.dat", uuid));
// after: create it before IO
std::fs::create_dir_all(&data_path)?;
let path = data_path.join(format!("{}.dat", uuid));
Defensive patterns

Strategy: validation

Validate before calling

let dir = data_path.as_ref();
if !dir.exists() { std::fs::create_dir_all(dir)?; }
let test = dir.join(".write_test");
std::fs::File::create(&test).and_then(|_| std::fs::remove_file(&test))?;

Type guard

fn playerdata_usable(dir: &Path) -> bool { dir.is_dir() && dir.metadata().map(|m| !m.permissions().readonly()).unwrap_or(false) }

Try / catch

match storage.load_player_data(uuid) {
    Err(PlayerDataError::Io(e)) => warn!("playerdata IO failed for {uuid}: {e}; using defaults"),
    other => other?,
}

Prevention

When it happens

Trigger: `PlayerDataStorage` read/write of `<world>/playerdata/<uuid>.dat` when the OS returns an error: missing directory, permission denied, disk full.

Common situations: Read-only world directory, world folder deleted or moved while server runs, permission problems after copying worlds between users/containers, disk quota exceeded.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/efce917abf4d4552. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-world/src/data/player_data.rs:21

use std::io;
use std::path::PathBuf;
use tracing::{debug, error};
use uuid::Uuid;

/// Manages the storage and retrieval of player data from disk and memory cache.
///
/// This struct provides functions to load and save player data to/from NBT files,
/// with a memory cache to handle player disconnections temporarily.
pub struct PlayerDataStorage {
    /// Path to the directory where player data is stored
    data_path: PathBuf,
    /// Whether player data saving is enabled
    save_enabled: bool,
}

#[derive(Debug, thiserror::Error)]
pub enum PlayerDataError {
    #[error("IO error: {0}")]
    Io(#[from] io::Error),
    #[error("NBT error: {0}")]
    Nbt(String),
}

impl PlayerDataStorage {
    /// Creates a new `PlayerDataStorage` with the specified data path and cache expiration time.
    pub fn new(data_path: impl Into<PathBuf>, enabled: bool) -> Self {
        let path = data_path.into();
        if !path.exists()
            && let Err(e) = create_dir_all(&path)
        {
            error!(
                "Failed to create player data directory at {}: {e}",
                path.display()
            );
        }

View on GitHub (pinned to 8d4639e25a)