clockworklabs/SpacetimeDB · error · anyhow::Error

Module bindings path

Error message

Module bindings path {} exists but is not a directory.

What it means

The module bindings destination already exists on disk but is not a directory (a regular file or symlink to a file). Since a bindings output must be a directory that may need to be created, dev/generate refuses to overwrite the file and bails.

Solutions

  1. Delete or rename the conflicting file
  2. Choose a different bindings directory that does not exist as a file

Example fix

# before
# $ ls bindings  ->  a file named 'bindings'
spacetime dev --module-bindings-path bindings

# after
rm bindings
spacetime dev --module-bindings-path bindings
Defensive patterns

Strategy: validation

Validate before calling

// check the bindings destination is absent or a directory
let meta = std::fs::metadata(&module_bindings_dir);
if let Ok(m) = meta {
    anyhow::ensure!(m.is_dir(), "{} exists but is not a directory", module_bindings_dir.display());
}

Prevention

When it happens

Trigger: `spacetime dev --module-bindings-path bindings` where `bindings` exists as a file; a config path pointing at a file created by another tool.

Common situations: A placeholder file created to reserve the name; build artifacts; case-insensitive filesystems where a differently-cased file collides.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@3653d2ed49 (2026-08-20). Data as JSON: /api/errors/8fa5988da761ab72. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/subcommands/dev.rs:605

                .and_then(|v| v.as_str())
        });
        if let Some(db_name) = db_to_persist
            && let Some(path) = create_local_spacetime_config_if_missing(&project_dir, db_name)?
        {
            println!("{} Created {}", "✓".green(), strip_verbatim_prefix(&path).display());
        }
    }

    if !module_bindings_dir.exists() {
        // Create the module bindings directory if it doesn't exist
        std::fs::create_dir_all(&module_bindings_dir).with_context(|| {
            format!(
                "Failed to create module bindings path {}",
                module_bindings_dir.display()
            )
        })?;
    } else if !module_bindings_dir.is_dir() {
        anyhow::bail!(
            "Module bindings path {} exists but is not a directory.",
            module_bindings_path.display()
        );
    }

    // Check if we need to login to maincloud
    // Either because --server maincloud was provided, or because any of the publish configs use maincloud
    let needs_maincloud_login = resolved_server == "maincloud"
        || spacetime_config
            .map(|c| {
                c.iter_all_targets().any(|target| {
                    target
                        .additional_fields
                        .get("server")
                        .and_then(|v| v.as_str())
                        .map(|s| s == "maincloud")
                        .unwrap_or(false)
                })

View on GitHub (pinned to 3653d2ed49)