{"record":{"id":"9b9dde5a0b0c5349","repo":"clockworklabs/SpacetimeDB","slug":"project-initialization-did-not-create-spacetimedb","errorCode":null,"errorMessage":"Project initialization did not create spacetimedb directory","messagePattern":"Project initialization did not create spacetimedb directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":440,"sourceCode":"            // If the project was created in a subdirectory, hint the user to cd into it\n            // and show useful CLI commands they can run from there.\n            let current_dir = std::env::current_dir().context(\"Failed to get current directory\")?;\n            let display_path = strip_verbatim_prefix(&canonical_created_path);\n            if display_path != current_dir {\n                let rel_path = display_path.strip_prefix(&current_dir).unwrap_or(display_path);\n                println!(\n                    \"\\n{} To interact with your database, open a new terminal and run:\",\n                    \"Tip:\".yellow().bold(),\n                );\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() {","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dev.rs#L422-L458","documentation":"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.","triggerScenarios":"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/`.","commonSituations":"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.","solutions":["Check the directory the CLI expected (`<project>/spacetimedb`) and create/populate it manually if init was interrupted","Retry in a clean directory: `spacetime dev` in a new empty folder and let init run again","If using a custom template, fix it so it creates the `spacetimedb` module directory","Rule out disk-space/permission issues on the project volume"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# After init, assert the expected layout before continuing\n[ -d ./spacetimedb ] || { echo \"init incomplete: missing ./spacetimedb\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// Non-retryable: abort dev, inspect/repair the scaffold (create spacetimedb/ or re-init in a clean dir), then start again.","preventionTips":["Use official templates; custom templates must create spacetimedb/","Exclude project dirs from sync/AV tools that may delete fresh output"],"tags":["cli","project-init","filesystem","spacetimedb"],"backgroundTag":"missing-generated-directory","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}