clockworklabs/SpacetimeDB · error

Project initialization did not create spacetimedb directory

Error message

Project initialization did not create spacetimedb directory

What it means

After `spacetime dev` initializes a new project (e.g. from a template) it verifies that the expected `spacetimedb` module directory exists on disk. If the init step reported success but the directory is missing, the CLI bails rather than continue with a broken project layout. The comment below it shows why it matters: publish configs are rebuilt from `spacetimedb_dir`, so a stale/missing path would corrupt subsequent publishes.

Source

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

            // If the project was created in a subdirectory, hint the user to cd into it
            // and show useful CLI commands they can run from there.
            let current_dir = std::env::current_dir().context("Failed to get current directory")?;
            let display_path = strip_verbatim_prefix(&canonical_created_path);
            if display_path != current_dir {
                let rel_path = display_path.strip_prefix(&current_dir).unwrap_or(display_path);
                println!(
                    "\n{} To interact with your database, open a new terminal and run:",
                    "Tip:".yellow().bold(),
                );
                println!("  cd ./{}", rel_path.display());
                println!("  spacetime call add Alice");
                println!("  spacetime sql \"SELECT * FROM person\"");
                println!("  spacetime logs");
                println!();
            }

            if !spacetimedb_dir.exists() {
                anyhow::bail!("Project initialization did not create spacetimedb directory");
            }

            // Clear publish_configs so they're rebuilt after init with the correct
            // spacetimedb_dir. Without this, configs built before init contain the
            // pre-init (stale) module path and the block below would overwrite the
            // correctly-updated spacetimedb_dir.
            publish_configs.clear();
        } else {
            anyhow::bail!("Not in a SpacetimeDB project directory");
        }
    } else if args.get_one::<String>("template").is_some() {
        println!(
            "{}",
            "Warning: --template option is ignored because a SpacetimeDB project already exists.".yellow()
        );
    }

    if let Some(config) = publish_configs.first() {

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Check the directory the CLI expected (`<project>/spacetimedb`) and create/populate it manually if init was interrupted
  2. Retry in a clean directory: `spacetime dev` in a new empty folder and let init run again
  3. If using a custom template, fix it so it creates the `spacetimedb` module directory
  4. Rule out disk-space/permission issues on the project volume
Defensive patterns

Strategy: try-catch

Validate before calling

# After init, assert the expected layout before continuing
[ -d ./spacetimedb ] || { echo "init incomplete: missing ./spacetimedb"; exit 1; }

Try / catch

// Non-retryable: abort dev, inspect/repair the scaffold (create spacetimedb/ or re-init in a clean dir), then start again.

Prevention

When it happens

Trigger: Project init (template clone / scaffolding) partially fails — e.g. git clone succeeded but files were moved, disk full, antivirus/permissions removing the folder, or a custom template that does not actually create `spacetimedb/`.

Common situations: Custom or third-party templates that emit a different layout; filesystem permissions or sync tools (OneDrive/Dropbox) interfering right after creation; interrupted init followed by a re-run.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/9b9dde5a0b0c5349. Report an issue: GitHub.