DioxusLabs/dioxus · error

Failed to read name of css module file

Error message

Failed to read name of css module file `{}`.

What it means

Guard in process_css_module when source.file_name() returns None or a non-UTF-8 OsStr, so no module name can be derived for hashing. The input at fault is the CSS module asset path; a valid .css module file always has a UTF-8 file name.

Solutions

  1. The CSS module file name could not be read. Give the file a valid UTF-8 name.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cli/src/opt/css.rs:58 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/a5133060dd8a8bc6. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/opt/css.rs:58

        )
    })?;

    Ok(())
}

pub(crate) fn process_css_module(
    css_options: &CssModuleAssetOptions,
    source: &Path,
    output_path: &Path,
) -> anyhow::Result<()> {
    let css = std::fs::read_to_string(source)?;

    // Collect the file hash name.
    let mut src_name = source
        .file_name()
        .and_then(|x| x.to_str())
        .ok_or_else(|| {
            anyhow!(
                "Failed to read name of css module file `{}`.",
                source.display()
            )
        })?
        .strip_suffix(".css")
        .ok_or_else(|| {
            anyhow!(
                "Css module file `{}` should end with a `.css` suffix.",
                source.display(),
            )
        })?
        .to_string();

    src_name.push('-');

    let hash = create_module_hash(source);
    let css = transform_css(css.as_str(), hash.as_str()).map_err(|error| {
        anyhow!(

View on GitHub (pinned to 24f6a829df)