Fix spacetime dev failing on C# projects#4317
Conversation
…h layered filtering The `spacetime dev` command hardcoded watching `spacetimedb_dir/src/`, which doesn't exist for C# templates where source files live directly in `spacetimedb_dir/`. This watches `spacetimedb_dir` itself with layered file-watch filtering to avoid triggering rebuilds on build artifacts: 1. Always-ignore list (VCS dirs, build output like target/bin/obj/node_modules) 2. Always-watch exception (.env.local, spacetime.*.local.json) 3. Gitignore rules (global, project-level, module-level)
There was a problem hiding this comment.
Reviewed the diff. The fix is correct and the filtering is well-designed. LGTM.
The file watch fix: Watching spacetimedb_dir instead of spacetimedb_dir/src/ fixes C# projects where source files live directly in the module directory.
The filtering: The three-layer ignore system (hardcoded dirs → always-watch exceptions → gitignore) is a clean design, and using the ignore crate for gitignore parsing is the right call. Good coverage of build artifact directories across Rust, .NET, JS/TS, Python, and IDEs.
Minor observations:
-
should_ignore_pathcallspath.is_dir()on every watcher event. ForRemoveevents the path may no longer exist, sois_dir()returnsfalse— a deleted directory could miss the gitignore dir-matching rule. Practical impact is just a spurious rebuild trigger, not a real bug. -
bininALWAYS_IGNORE_DIRScould theoretically match a non-artifactbin/directory, but in the context of SpacetimeDB templates this is always .NET build output.
Summary
spacetime devhardcoded watchingspacetimedb_dir/src/, which doesn't exist for C# templates (source files are directly inspacetimedb_dir/)spacetimedb_diritself with layered file-watch filtering to avoid triggering rebuilds on build artifactstarget/,bin/,obj/,node_modules/; (2) always-watch exceptions like.env.local; (3).gitignorerules from global, project, and module levelsTest plan
cargo build -p spacetimedb-clicompiles successfullyspacetime dev --template basic-cs <db>no longer errors with "Input watch path is neither a file nor a directory".csfile inspacetimedb/triggers a rebuildobj//bin/do not trigger rebuildsspacetimedb/src/exists) continue to work as before