{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":447,"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":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/cli/src/subcommands/dev.rs#L429-L465","documentation":"After `spacetime dev` scaffolds a new project (the init flow), the code asserts that the expected spacetimedb module directory now exists. If the initializer reported success but did not create the directory, dev aborts with this message instead of continuing against a missing module.","triggerScenarios":"A custom or modified template whose init step exits 0 without creating the spacetimedb directory; init that partially fails (e.g. clone succeeded but post-processing did not run).","commonSituations":"Custom project templates; filesystem permission problems silently swallowing the directory creation; init commands that skip module scaffolding.","solutions":["Scroll up and inspect the init output for the real failure","Create the directory manually (`mkdir spacetimedb`) and re-run","If using a custom template, fix it so it actually creates the module directory"],"exampleFix":"# before\nspacetime dev --init\n# error: Project initialization did not create spacetimedb directory\n\n# after\nmkdir spacetimedb\nspacetime dev","handlingStrategy":"validation","validationCode":"// after running init, verify the scaffold actually produced the module dir\ninit.execute()?;\nlet dir = project_dir.join(\"spacetimedb\");\nanyhow::ensure!(dir.exists(), \"init did not create {}\", dir.display());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test custom templates on each init path before relying on them","Watch init output for silently swallowed filesystem errors"],"tags":["cli","dev","init","filesystem"],"backgroundTag":"missing-expected-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"}