Skip to content

Fix spacetime dev failing on C# projects#4317

Open
cloutiertyler wants to merge 1 commit intomasterfrom
tyler/dev-watch-filtering
Open

Fix spacetime dev failing on C# projects#4317
cloutiertyler wants to merge 1 commit intomasterfrom
tyler/dev-watch-filtering

Conversation

@cloutiertyler
Copy link
Contributor

Summary

  • spacetime dev hardcoded watching spacetimedb_dir/src/, which doesn't exist for C# templates (source files are directly in spacetimedb_dir/)
  • Now watches spacetimedb_dir itself with layered file-watch filtering to avoid triggering rebuilds on build artifacts
  • Filtering layers: (1) always-ignore dirs like target/, bin/, obj/, node_modules/; (2) always-watch exceptions like .env.local; (3) .gitignore rules from global, project, and module levels

Test plan

  • cargo build -p spacetimedb-cli compiles successfully
  • spacetime dev --template basic-cs <db> no longer errors with "Input watch path is neither a file nor a directory"
  • Modifying a .cs file in spacetimedb/ triggers a rebuild
  • Build artifacts in obj//bin/ do not trigger rebuilds
  • Rust projects (spacetimedb/src/ exists) continue to work as before

…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)
Copy link
Collaborator

@clockwork-labs-bot clockwork-labs-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. should_ignore_path calls path.is_dir() on every watcher event. For Remove events the path may no longer exist, so is_dir() returns false — a deleted directory could miss the gitignore dir-matching rule. Practical impact is just a spurious rebuild trigger, not a real bug.

  2. bin in ALWAYS_IGNORE_DIRS could theoretically match a non-artifact bin/ directory, but in the context of SpacetimeDB templates this is always .NET build output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants