{"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":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":456,"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":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/cli/src/subcommands/dev.rs#L438-L474","documentation":"`spacetime dev` could not find a SpacetimeDB project: the current operation neither matched an existing project (no spacetimedb directory or module path) nor went through the init branch, so the command refuses to continue. It is a 'you are in the wrong place' error.","triggerScenarios":"Running `spacetime dev` from a directory that has no spacetimedb/ dir, no module-path configuration, and no spacetime.json, without --project-path or --module-path.","commonSituations":"Wrong terminal or cwd; running from the repo root instead of the module directory; cloning a project and running dev before scaffolding.","solutions":["cd into the project directory or pass --project-path","Scaffold first: use the init/template flow to create the project","Provide --module-path pointing at your module directory"],"exampleFix":"# before\nspacetime dev            # run from ~\n\n# after\ncd ~/projects/my-game\nspacetime dev --project-path .","handlingStrategy":"validation","validationCode":"// detect a SpacetimeDB project before running dev\nfn is_project_dir(dir: &std::path::Path) -> bool {\n    dir.join(\"spacetimedb\").exists()\n        || dir.join(\"spacetime.json\").exists()\n        || dir.join(\"spacetime.toml\").exists()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `spacetime dev` from the project root or pass --project-path","Scaffold with the init/template flow before the first dev run"],"tags":["cli","dev","project","cwd"],"backgroundTag":"missing-project-directory","analyzedSha":"3653d2ed498fddbd83b7062aa6bf8970e18635ec","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}