{"record":{"id":"1576bdf2da2c2cf4","repo":"clockworklabs/SpacetimeDB","slug":"template-has-no-git-tracked-files-check-that","errorCode":null,"errorMessage":"Template '{}' has no git-tracked files! Check that the directory exists and contains files tracked by git.","messagePattern":"Template '(.+?)' has no git-tracked files! Check that the directory exists and contains files tracked by git\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/build.rs","lineNumber":262,"sourceCode":"}\n\nfn generate_templates_json(templates: &[TemplateInfo]) -> String {\n    let payload = TemplatesJson { templates };\n    serde_json::to_string_pretty(&payload).expect(\"Failed to serialize templates JSON\")\n}\n\nfn serialize_option_string_as_empty<S>(value: &Option<String>, serializer: S) -> Result<S::Ok, S::Error>\nwhere\n    S: serde::Serializer,\n{\n    serializer.serialize_str(value.as_deref().unwrap_or(\"\"))\n}\n\nfn generate_template_entry(code: &mut String, template_path: &Path, source: &str, manifest_dir: &Path) {\n    let (git_files, resolved_base) = get_git_tracked_files(template_path, manifest_dir);\n\n    if git_files.is_empty() {\n        panic!(\"Template '{}' has no git-tracked files! Check that the directory exists and contains files tracked by git.\", source);\n    }\n\n    let repo_root = get_repo_root();\n\n    code.push_str(\"    {\\n\");\n    code.push_str(\"        let mut files = HashMap::new();\\n\");\n\n    for file_path in git_files {\n        // Example file_path: modules/chat-console-rs/src/lib.rs (relative to repo root)\n        // Example resolved_base: modules/chat-console-rs\n        // Example relative_path: src/lib.rs\n        let relative_path = match file_path.strip_prefix(&resolved_base) {\n            Ok(p) => p,\n            Err(_) => {\n                eprintln!(\n                    \"Warning: Could not strip prefix '{}' from '{}' for source '{}'\",\n                    resolved_base.display(),\n                    file_path.display(),","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/build.rs#L244-L280","documentation":"Build-time panic in crates/cli/build.rs while generating the embedded template registry: the template directory exists as an entry in templates-list.json but `git ls-files` (or the Nix file listing) returned zero tracked files for it. The CLI embeds template files into the binary at compile time, so an empty result means nothing would be embedded for that template — the build refuses to produce a CLI with a silently-empty template.","triggerScenarios":"Adding a new template directory and an entry in templates/templates-list.json without `git add`ing the files; building the CLI from an exported tarball/source copy where .git metadata is absent while the non-Nix path runs `git ls-files`; renaming a template dir in the list but not on disk.","commonSituations":"Contributors who create template files but forget to stage them; building inside a Docker context that strips .git; CI checking out with a partial clone that excludes the template paths.","solutions":["From the repo root, stage the template: `git add templates/<template-name>` and confirm `git ls-files templates/<template-name>` lists files.","Verify the `directory`/source field in templates/templates-list.json matches the on-disk folder name exactly (typo = zero matches).","If building without git intentionally (e.g. Docker), set `SPACETIMEDB_NIX_BUILD_GIT_COMMIT` to switch build.rs onto the list-all-files path, or copy the full .git directory into the build context.","Re-run `cargo build -p spacetimedb-cli` (or `spacetime build` of the CLI crate)."],"exampleFix":"# before\ngit status --short  # shows ?? templates/my-template/\n\n# after\ngit add templates/my-template\ngit commit -m \"Add my-template\"\ncargo build -p spacetimedb-cli","handlingStrategy":"validation","validationCode":"# Run from the repo root before building the CLI:\nfor d in $(jq -r '.templates[].directory' templates/templates-list.json); do\n  count=$(git ls-files \"templates/$d\" | wc -l)\n  [ \"$count\" -gt 0 ] || echo \"template $d has 0 git-tracked files\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["`git add` new template directories in the same commit that adds the list entry.","Never build the CLI from a source copy with .git stripped (or set SPACETIMEDB_NIX_BUILD_GIT_COMMIT to take the list-all path).","Run the ls-files check in CI for every PR touching templates/."],"tags":["spacetimedb","build-script","git","templates","file-not-tracked"],"backgroundTag":"missing-git-tracked-files","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}