clockworklabs/SpacetimeDB · error · anyhow::Error

No templates found for selected language

Error message

No templates found for selected language

What it means

During fully-interactive `spacetime init`, template metadata is fetched remotely and grouped into a BTreeMap keyed by language label; lang_keys is built directly from that map's keys (init.rs:864). The lookup at init.rs:887 therefore cannot fail under normal construction — this 'No templates found for selected language' error is a defensive guard against state mutation or index/key desynchronization between building the menu and handling the selection.

Solutions

  1. Re-run `spacetime init` — transient inconsistency will not persist across runs
  2. Bypass interactive selection: `spacetime init --template <template-id>` to choose directly
  3. If it reproduces consistently, update the CLI (`spacetime version`) and report the issue with the template list output to SpacetimeDB

Example fix

# before (interactive, hit the guard)
spacetime init
# after (direct template selection)
spacetime init --template quickstart-csharp
Defensive patterns

Strategy: retry

Try / catch

for i in 1 2 3; do spacetime init --template "$TEMPLATE_ID" && break; echo "attempt $i failed, retrying"; done

Prevention

When it happens

Trigger: Selecting a language in the interactive FuzzySelect menu when templates_by_lang no longer contains the selected key — effectively unreachable unless the map is mutated between menu construction (line 848-872) and selection handling, or a CLI bug desynchronizes lang_keys from templates_by_lang.

Common situations: Hitting a CLI build where the two collections were built from different template fetches; extremely rare — if reproducible it indicates a bug worth reporting rather than a user misconfiguration.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-08-20). Data as JSON: /api/errors/7180ea000389b92f. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/subcommands/init.rs:893

        })
        .collect();
    lang_items.push("Clone from GitHub (owner/repo or git URL)".to_string());
    lang_items.push("None".to_string());

    let github_clone_index = lang_keys.len();
    let none_index = lang_keys.len() + 1;
    loop {
        let client_selection = FuzzySelect::with_theme(&theme)
            .with_prompt("Select a language (type to filter)")
            .items(&lang_items)
            .default(0)
            .interact()?;

        if client_selection < lang_keys.len() {
            let selected_lang = &lang_keys[client_selection];
            let template_indices = templates_by_lang
                .get(selected_lang)
                .ok_or_else(|| anyhow::anyhow!("No templates found for selected language"))?;

            let template = if template_indices.len() > 1 {
                let template_items: Vec<String> = template_indices
                    .iter()
                    .map(|&idx| {
                        let template = &templates[idx];
                        format!("{} - {}", template.id, template.description)
                    })
                    .collect();

                let pair_prompt = format!("Templates available for {selected_lang} (type to filter, Esc to go back)");
                let template_selection = FuzzySelect::with_theme(&theme)
                    .with_prompt(&pair_prompt)
                    .items(&template_items)
                    .default(0)
                    .interact_opt()?;

                let Some(template_selection) = template_selection else {

View on GitHub (pinned to fdd647dfac)