clockworklabs/SpacetimeDB · error · anyhow::Error

Missing loaded config directory

Error message

Missing loaded config directory

What it means

During `spacetime dev`, if no module path can be found the CLI interactively offers to prompt for one. That prompt needs a base directory to resolve relative paths against, taken from loaded_config.config_dir (the directory of the discovered spacetime.json). When loaded_config is None — no project config file was found — there is no base directory, so the command errors with 'Missing loaded config directory' after you accept the prompt.

Solutions

  1. Pass the module path explicitly so the prompt never runs: `spacetime dev --module-path ./spacetimedb`
  2. Create or move a spacetime.json in the project directory (or a parent of it) so config discovery succeeds and config_dir exists
  3. Run `spacetime init` first to scaffold a project with a config file, then re-run dev

Example fix

# before (no spacetime.json anywhere up the tree)
spacetime dev
# -> prompt -> Yes -> 'Missing loaded config directory'

# after
spacetime dev --module-path ./server
Defensive patterns

Strategy: validation

Validate before calling

# Before dev, ensure a config exists or pass the module path explicitly:
if [ ! -f spacetime.json ]; then
  spacetime dev --module-path ./spacetimedb "$@"
else
  spacetime dev "$@"
fi

Prevention

When it happens

Trigger: Running `spacetime dev` in a directory tree with no spacetime.json, without --module-path, and answering 'Yes' to 'Would you like to provide --module-path now?'. The preceding guard already bails if you answer No; this branch bails because the interactive prompt cannot resolve relative module paths without a config dir.

Common situations: First-run of dev in a brand-new/empty folder before `spacetime init`; running dev from the wrong terminal tab/cwd; a spacetime.json that was renamed or is one directory above the cwd outside the search scope; CI/non-TTY environments where the config discovery silently found nothing.

Related errors


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

Appendix: source

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

                .unwrap_or_else(|| "spacetime.json".to_string());
            println!("{} {}", "Found config files:".yellow().bold(), files.dimmed());
            println!(
                "{}",
                "Could not determine module path because no `module-path` was found and `./spacetimedb` does not exist."
                    .yellow()
            );
            let should_provide = Confirm::new()
                .with_prompt("Would you like to provide --module-path now?")
                .default(true)
                .interact()?;
            if !should_provide {
                anyhow::bail!("Cannot continue without a module path.");
            }

            let config_dir = loaded_config
                .as_ref()
                .map(|lc| lc.config_dir.clone())
                .ok_or_else(|| anyhow::anyhow!("Missing loaded config directory"))?;

            let provided_module_path: String = Input::with_theme(&ColorfulTheme::default())
                .with_prompt("Module path")
                .default("spacetimedb".to_string())
                .validate_with({
                    let config_dir = config_dir.clone();
                    move |input: &String| -> Result<(), String> {
                        let candidate = PathBuf::from(input);
                        let resolved = if candidate.is_absolute() {
                            candidate
                        } else {
                            config_dir.join(&candidate)
                        };
                        if resolved.exists() {
                            Ok(())
                        } else {
                            Err(format!(
                                "Path does not exist: {} (resolved to {})",

View on GitHub (pinned to 3653d2ed49)