{"record":{"id":"e9dbf5adce2871d5","repo":"clockworklabs/SpacetimeDB","slug":"login-required-to-publish-to-maincloud-server","errorCode":null,"errorMessage":"Login required to publish to maincloud server","messagePattern":"Login required to publish to maincloud server","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":634,"sourceCode":"                c.iter_all_targets().any(|target| {\n                    target\n                        .additional_fields\n                        .get(\"server\")\n                        .and_then(|v| v.as_str())\n                        .map(|s| s == \"maincloud\")\n                        .unwrap_or(false)\n                })\n            })\n            .unwrap_or(false);\n\n    if needs_maincloud_login && config.spacetimedb_token().is_none() {\n        let should_login = Confirm::new()\n            .with_prompt(\"Would you like to sign in now?\")\n            .default(true)\n            .interact()?;\n        if !should_login && server_from_cli.is_some() {\n            // The user explicitly provided --server maincloud but doesn't want to log in\n            anyhow::bail!(\"Login required to publish to maincloud server\");\n        } else if !should_login {\n            // Print warning saying that without logging in we will use local server regardless\n            // of what their default server is in their config\n            println!(\n                \"{} {}\",\n                \"Warning:\".yellow().bold(),\n                \"Without logging in, the local server will be used regardless of your default server.\".dimmed()\n            );\n            // Switch the server to local\n            resolved_server = \"local\";\n        } else {\n            // Login\n            get_login_token_or_log_in(&mut config, Some(resolved_server), !force).await?;\n        }\n    }\n\n    // Determine client command: CLI flag > config file > auto-detect (and save)\n    let server_only = args.get_flag(\"server-only\");","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/cli/src/subcommands/dev.rs#L616-L652","documentation":"`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).","triggerScenarios":"`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.","commonSituations":"Fresh machines, expired or missing credentials, CI environments without a token, users working offline.","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"],"exampleFix":"# before\nspacetime dev --server maincloud    # declined sign-in\n\n# after\nspacetime login\nspacetime dev --server maincloud","handlingStrategy":"validation","validationCode":"// before publishing to maincloud, ensure a token exists\nif resolved_server == \"maincloud\" && config.spacetimedb_token().is_none() {\n    anyhow::bail!(\"run `spacetime login` first or provide a token\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","auth","login","maincloud","dev"],"backgroundTag":"authentication-required","analyzedSha":"3653d2ed498fddbd83b7062aa6bf8970e18635ec","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}