Skip to content

Commit 4df71be

Browse files
authored
Fix spacetime dev bug when running with a project path (#4809)
# Description of Changes Fixes an issue where running `spacetime dev <database name> --template chat-react-ts --server maincloud` for an existing database and a new local project folder would fail with this error: ```sh Building... Error: Failed to build project Caused by: Module directory does not exist: '/Users/aasoni/./spacetimedb'. Check your --module-path flag or the module-path setting in spacetime.json. ``` Summary of the bug: - determine_publish_configs was called at line 373 before the project existed, storing <cwd>/./spacetimedb as the module path - After init correctly updated spacetimedb_dir to the new project's path, a later block (lines 454-468) re-read the stale path from the early publish config and overwrote the correct value - The rebuild guard at line 498 never triggered because publish_configs was non-empty (due to the database name CLI argument) The fix clears publish_configs at the end of the init block, causing the rebuild at line 498 to run with the correct, post-init spacetimedb_dir. # API and ABI breaking changes No # Expected complexity level and risk 1 # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] Re-ran `spacetime dev` with various flags to confirm they all still worked - [x] Verified that the specific error case was fixed
1 parent 8e02165 commit 4df71be

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • crates/cli/src/subcommands

crates/cli/src/subcommands/dev.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
435435
if !spacetimedb_dir.exists() {
436436
anyhow::bail!("Project initialization did not create spacetimedb directory");
437437
}
438+
439+
// Clear publish_configs so they're rebuilt after init with the correct
440+
// spacetimedb_dir. Without this, configs built before init contain the
441+
// pre-init (stale) module path and the block below would overwrite the
442+
// correctly-updated spacetimedb_dir.
443+
publish_configs.clear();
438444
} else {
439445
anyhow::bail!("Not in a SpacetimeDB project directory");
440446
}

0 commit comments

Comments
 (0)