bevyengine/bevy · error · AssetWriterError::Io

no such dir

Error message

no such dir

What it means

AssetWriterError::Io with ErrorKind::NotFound and message 'no such dir', returned by the memory writer's remove_directory when the target directory does not exist in the in-memory asset hierarchy. Like a real filesystem, deleting a missing directory is an error.

Source

Thrown at crates/bevy_asset/src/io/memory.rs:570

        };
        self.root.insert_meta(new_path, old_meta.value);
        // Remove the meta after instead of before since otherwise there'd be a moment where the
        // Dir is unlocked and missing both the old and new paths. This just prevents race
        // conditions.
        self.root.remove_metadata(old_path);
        Ok(())
    }

    async fn create_directory<'a>(&'a self, path: &'a Path) -> Result<(), AssetWriterError> {
        // Just pretend we're on a file system that doesn't consider directory re-creation a
        // failure.
        self.root.get_or_insert_dir(path);
        Ok(())
    }

    async fn remove_directory<'a>(&'a self, path: &'a Path) -> Result<(), AssetWriterError> {
        if self.root.remove_dir(path).is_none() {
            return Err(AssetWriterError::Io(Error::new(
                ErrorKind::NotFound,
                "no such dir",
            )));
        }
        Ok(())
    }

    async fn remove_empty_directory<'a>(&'a self, path: &'a Path) -> Result<(), AssetWriterError> {
        let Some(dir) = self.root.get_dir(path) else {
            return Err(AssetWriterError::Io(Error::new(
                ErrorKind::NotFound,
                "no such dir",
            )));
        };

        let dir = dir.0.read().unwrap();
        if !dir.assets.is_empty() || !dir.metadata.is_empty() || !dir.dirs.is_empty() {
            return Err(AssetWriterError::Io(Error::new(

View on GitHub (pinned to 396ca72708)

Solutions

  1. Verify the directory path exists in the memory source before removing it
  2. Create the directory first if your flow requires remove-then-recreate
  3. Ignore/handle NotFound when the directory's absence is an acceptable end state
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_asset/src/io/memory.rs:570 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/d20fa1c9dec17f09. Report an issue: GitHub.