DioxusLabs/dioxus · error · anyhow::Error

Cannot copy global asset '{}' for component '{}' because it

Error message

Cannot copy global asset '{}' for component '{}' because it is outside of the component registry '{}'

What it means

Path-containment guard in copy_global_assets (called from add_component): after canonicalizing the registry root and the component's global asset path, the source resolves to a location outside the canonicalized registry root, so copying it would pull in files that are not part of the component registry (a potential path-traversal or misconfigured registry layout). The inputs at fault are the component's global_assets path and the registry layout.

Source

Thrown at packages/cli/src/cli/component.rs:811

async fn copy_global_assets(
    registry_root: &Path,
    assets_root: &Path,
    component: &ResolvedComponent,
) -> Result<()> {
    let canonical_registry_root = dunce::canonicalize(registry_root)?;
    for path in &component.global_assets {
        let src = component.path.join(path);
        let absolute_source = dunce::canonicalize(&src).with_context(|| {
            format!(
                "Failed to find global asset '{}' for component '{}'",
                src.display(),
                component.name
            )
        })?;

        // Make sure the source is inside the component registry somewhere
        if !absolute_source.starts_with(&canonical_registry_root) {
            bail!(
                "Cannot copy global asset '{}' for component '{}' because it is outside of the component registry '{}'",
                absolute_source.display(),
                component.name,
                canonical_registry_root.display()
            );
        }

        // Copy the file into the assets directory, preserving the file name and extension
        let dest = assets_root.join(
            absolute_source
                .components()
                .next_back()
                .context("Global assets must have at least one file component")?,
        );

        // Make sure the asset dir exists
        if let Some(parent) = dest.parent() {
            if !parent.exists() {

View on GitHub (pinned to 24f6a829df)

Solutions

  1. The global asset lies outside the component registry. Move the asset inside the registry or fix the component manifest.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cli/src/cli/component.rs:811 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/427277c7576f0da8. Report an issue: GitHub.