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` determined the publish target needs maincloud, found no saved login token, and the user declined the sign-in prompt. Because `--server maincloud` was passed explicitly, the CLI aborts instead of silently falling back to the local server (the fallback only applies when maincloud was inferred from config targets).
Solutions
- Re-run and accept the sign-in prompt, or log in first: `spacetime login`
- Provide a token non-interactively via the CLI config or environment so no prompt is needed
- Drop `--server maincloud` if the local server was actually intended
Example fix
# before spacetime dev --server maincloud # declined sign-in # after spacetime login spacetime dev --server maincloud
Defensive patterns
Strategy: validation
Validate before calling
// before publishing to maincloud, ensure a token exists
if resolved_server == "maincloud" && config.spacetimedb_token().is_none() {
anyhow::bail!("run `spacetime login` first or provide a token");
} Prevention
- Run `spacetime login` before scripting dev against maincloud
- Store a long-lived token in the CLI config for CI instead of relying on the interactive prompt
When it happens
Trigger: `spacetime dev --server maincloud` with no spacetimedb token configured and 'No' at the 'Would you like to sign in now?' prompt; or maincloud publish/generate targets in config with no token.
Common situations: Fresh machines, expired or missing credentials, CI environments without a token, users working offline.
Related errors
- Failed to get token
- Failed to request token
- Response data is missing.
- Session token is missing in response.
- Unknown error
AI-assisted analysis of clockworklabs/SpacetimeDB@3653d2ed49 (2026-08-20).
Data as JSON: /api/errors/e9dbf5adce2871d5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/dev.rs:634
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 3653d2ed49)