DioxusLabs/dioxus · error

Couldn't read public directory at {:?}: {}

Error message

Couldn't read public directory at {:?}: {}

What it means

serve_dir_cached could not read the static assets directory (exe/public or the configured public path). std::fs::read_dir failed — typically the directory does not exist or lacks read permissions — so the fullstack server cannot mount static assets.

Source

Thrown at packages/fullstack-server/src/server.rs:409

    // The CLI always bundles static assets into the exe/public directory
    Some(
        std::env::current_exe()
            .ok()?
            .parent()
            .unwrap()
            .join("public"),
    )
}

fn serve_dir_cached<S>(mut router: Router<S>, public_path: &Path, directory: &Path) -> Router<S>
where
    S: Send + Sync + Clone + 'static,
{
    use tower_http::services::{ServeDir, ServeFile};

    let dir = std::fs::read_dir(directory)
        .unwrap_or_else(|e| panic!("Couldn't read public directory at {:?}: {}", &directory, e));

    for entry in dir.flatten() {
        let path = entry.path();
        // Don't serve the index.html file. The SSR handler will generate it.
        if path == public_path.join("index.html") {
            continue;
        }

        let route = format!(
            "/{}",
            path.strip_prefix(public_path)
                .unwrap()
                .iter()
                .map(|segment| segment.to_string_lossy())
                .collect::<Vec<_>>()
                .join("/")
        );

View on GitHub (pinned to 24f6a829df)

Solutions

  1. The public directory cannot be read. Create it, fix the configured path, or correct its permissions.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/fullstack-server/src/server.rs:409 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/4d9d57143e5f45da. Report an issue: GitHub.