clockworklabs/SpacetimeDB · error · anyhow::Error

Module bindings path must be a relative path

Error message

Module bindings path must be a relative path

What it means

`spacetime dev` requires --module-bindings-path to be a relative path because it is joined onto the project directory to form the destination. An absolute path is rejected up front rather than being silently mis-joined or overriding the project anchor.

Solutions

  1. Pass a path relative to the project directory (e.g. `bindings` or `../shared-bindings`)
  2. If you need a fixed location, anchor it via --project-path and express the bindings path relatively

Example fix

# before
spacetime dev --module-bindings-path /home/me/proj/bindings

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

Strategy: validation

Validate before calling

// reject absolute bindings paths before running dev
if module_bindings_path.is_absolute() {
    anyhow::bail!("--module-bindings-path must be relative to the project dir");
}

Prevention

When it happens

Trigger: Passing an absolute module bindings path on the CLI (`spacetime dev --module-bindings-path /home/me/proj/bindings`) or configuring one absolutely, then running dev/generate.

Common situations: CI scripts building paths from $PWD; shell completion inserting absolute paths; editors or codegen tools emitting absolute output dirs.

Related errors


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

Appendix: source

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

    // If you don't specify a server, we default to your default server
    // If you don't have one of those, we default to "maincloud"
    let server_from_cli = args.get_one::<String>("server").map(|s| s.as_str());

    let default_server_name = config.default_server_name().map(|s| s.to_string());

    let mut resolved_server = server_from_cli
        .or(default_server_name.as_deref())
        .ok_or_else(|| anyhow::anyhow!("Server not specified and no default server configured."))?;

    let cwd = std::env::current_dir()?;
    let mut project_dir = if project_path.is_absolute() {
        project_path.clone()
    } else {
        cwd.join(project_path)
    };

    if module_bindings_path.is_absolute() {
        anyhow::bail!("Module bindings path must be a relative path");
    }
    let mut module_bindings_dir = project_dir.join(module_bindings_path);

    let mut spacetimedb_dir = match module_path_from_cli {
        Some(path) => {
            if path.is_absolute() {
                path.clone()
            } else {
                std::env::current_dir()?.join(path)
            }
        }
        None => project_dir.join("spacetimedb"),
    };

    let no_config = args.get_flag("no_config");
    let skip_publish = args.get_flag("skip_publish");
    let skip_generate = args.get_flag("skip_generate");
    let native_aot_from_cli = args.get_flag("native_aot");

View on GitHub (pinned to 3653d2ed49)