{"record":{"id":"e8f0ed2213d780ce","repo":"clockworklabs/SpacetimeDB","slug":"not-in-a-spacetimedb-project-directory","errorCode":null,"errorMessage":"Not in a SpacetimeDB project directory","messagePattern":"Not in a SpacetimeDB project directory","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":449,"sourceCode":"                );\n                println!(\"  cd ./{}\", rel_path.display());\n                println!(\"  spacetime call add Alice\");\n                println!(\"  spacetime sql \\\"SELECT * FROM person\\\"\");\n                println!(\"  spacetime logs\");\n                println!();\n            }\n\n            if !spacetimedb_dir.exists() {\n                anyhow::bail!(\"Project initialization did not create spacetimedb directory\");\n            }\n\n            // Clear publish_configs so they're rebuilt after init with the correct\n            // spacetimedb_dir. Without this, configs built before init contain the\n            // pre-init (stale) module path and the block below would overwrite the\n            // correctly-updated spacetimedb_dir.\n            publish_configs.clear();\n        } else {\n            anyhow::bail!(\"Not in a SpacetimeDB project directory\");\n        }\n    } else if args.get_one::<String>(\"template\").is_some() {\n        println!(\n            \"{}\",\n            \"Warning: --template option is ignored because a SpacetimeDB project already exists.\".yellow()\n        );\n    }\n\n    if let Some(config) = publish_configs.first() {\n        // if we have publish configs and we're past spacetimedb_dir manipulation,\n        // we should set spacetimedb_dir to the path of the first config as this will be\n        // later used for next steps\n        if let Some(path) = config\n            .get_one::<PathBuf>(\"module_path\")\n            .context(\"failed to read module_path from config\")?\n        {\n            spacetimedb_dir = if path.is_absolute() {\n                path","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dev.rs#L431-L467","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (in ~)\nspacetime dev\n# after\nspacetime dev --project-path ~/code/my-spdb-app","handlingStrategy":"validation","validationCode":"# Guard the invocation on project markers\nif [ ! -f spacetime.json ] && [ ! -d spacetimedb ]; then\n  echo \"not a SpacetimeDB project\"; exit 1\nfi\nspacetime dev","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run dev from the project root; use --project-path in monorepos","Keep spacetime.json at the root you invoke from"],"tags":["cli","project-structure","cwd","spacetimedb"],"backgroundTag":"not-in-project-directory","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}