clockworklabs/SpacetimeDB · error · anyhow::Error

Login required to publish to maincloud server

Error message

Login required to publish to maincloud server

What it means

`spacetime dev` detected that maincloud is required (explicit `--server maincloud`, or publish configs targeting it) and there is no spacetimedb token in config. It offers an interactive sign-in; this error means the user declined AND had explicitly passed `--server maincloud` on the command line — an explicit server choice cannot be silently downgraded to local, so the run aborts.

Source

Thrown at crates/cli/src/subcommands/dev.rs:612

                c.iter_all_targets().any(|target| {
                    target
                        .additional_fields
                        .get("server")
                        .and_then(|v| v.as_str())
                        .map(|s| s == "maincloud")
                        .unwrap_or(false)
                })
            })
            .unwrap_or(false);

    if needs_maincloud_login && config.spacetimedb_token().is_none() {
        let should_login = Confirm::new()
            .with_prompt("Would you like to sign in now?")
            .default(true)
            .interact()?;
        if !should_login && server_from_cli.is_some() {
            // The user explicitly provided --server maincloud but doesn't want to log in
            anyhow::bail!("Login required to publish to maincloud server");
        } else if !should_login {
            // Print warning saying that without logging in we will use local server regardless
            // of what their default server is in their config
            println!(
                "{} {}",
                "Warning:".yellow().bold(),
                "Without logging in, the local server will be used regardless of your default server.".dimmed()
            );
            // Switch the server to local
            resolved_server = "local";
        } else {
            // Login
            get_login_token_or_log_in(&mut config, Some(resolved_server), !force).await?;
        }
    }

    // Determine client command: CLI flag > config file > auto-detect (and save)
    let server_only = args.get_flag("server-only");

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Answer `y` at the sign-in prompt to authenticate against maincloud
  2. Or log in beforehand: `spacetime server login maincloud` / `spacetime login`
  3. Or drop the explicit flag and target a local server: `spacetime dev --server local`
  4. In scripts, ensure a token exists (`spacetime server list`, then login) before invoking dev with maincloud

Example fix

# before
spacetime dev --server maincloud  # answered 'n' at sign-in
# after
spacetime login && spacetime dev --server maincloud
Defensive patterns

Strategy: validation

Validate before calling

# Fail fast in scripts if no token for maincloud
spacetime server list >/dev/null
spacetime identity show --server maincloud >/dev/null 2>&1 || spacetime server login maincloud
spacetime dev --server maincloud

Prevention

When it happens

Trigger: `spacetime dev --server maincloud` while logged out, then answering 'no' to `Would you like to sign in now?`. Also when a config targets maincloud and the flag was given explicitly.

Common situations: Testing dev mode without intending to touch cloud; expired/missing token after clearing config; CI or non-interactive shells where the Confirm prompt reads a default 'no'.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/e9dbf5adce2871d5. Report an issue: GitHub.