clockworklabs/SpacetimeDB · error · anyhow::Error
Not in a SpacetimeDB project directory
Error message
Not in a SpacetimeDB project directory
What it means
`spacetime dev` bails with this when it needs an existing project (no init was performed this run) but the current layout is not recognized as a SpacetimeDB project — i.e. no `spacetimedb` directory and no usable `spacetime.json`/config was found at the resolved project path.
Source
Thrown at crates/cli/src/subcommands/dev.rs:449
);
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() {
// if we have publish configs and we're past spacetimedb_dir manipulation,
// we should set spacetimedb_dir to the path of the first config as this will be
// later used for next steps
if let Some(path) = config
.get_one::<PathBuf>("module_path")
.context("failed to read module_path from config")?
{
spacetimedb_dir = if path.is_absolute() {
pathView on GitHub (pinned to 524b4487d9)
Solutions
- cd into the directory containing `spacetime.json` (or the `spacetimedb/` module folder) and re-run
- Point at the right place: `spacetime dev --project-path path/to/project`
- If starting fresh, run `spacetime init` (or let `spacetime dev` init) to scaffold a project first
- Verify `spacetime.json` exists, is valid JSON, and sits at the project root you targeted
Example fix
# before (in ~) spacetime dev # after spacetime dev --project-path ~/code/my-spdb-app
Defensive patterns
Strategy: validation
Validate before calling
# Guard the invocation on project markers if [ ! -f spacetime.json ] && [ ! -d spacetimedb ]; then echo "not a SpacetimeDB project"; exit 1 fi spacetime dev
Prevention
- Run dev from the project root; use --project-path in monorepos
- Keep spacetime.json at the root you invoke from
When it happens
Trigger: Running `spacetime dev` in an unrelated directory; `--project-path` pointing at a folder without `spacetime.json` or `spacetimedb/`; config file exists but is empty/invalid so it does not count as a project.
Common situations: Wrong terminal/cwd (typing `spacetime dev` in `~` or a client repo); typos in `--project-path`; renamed or deleted `spacetime.json`; nested monorepo where the project root differs from cwd.
Related errors
- Could not detect the language of the module. Are you in a Sp
- Unsupported --dotnet-version {version}. Supported values: 8,
- No such saved server configuration: {server} Add a new serve
- No default server configuration. Set an existing server as t
- Server nickname {} already in use: {}://{}
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/e8f0ed2213d780ce.
Report an issue: GitHub.