{"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":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":612,"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":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dev.rs#L594-L630","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"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'.","solutions":["Answer `y` at the sign-in prompt to authenticate against maincloud","Or log in beforehand: `spacetime server login maincloud` / `spacetime login`","Or drop the explicit flag and target a local server: `spacetime dev --server local`","In scripts, ensure a token exists (`spacetime server list`, then login) before invoking dev with maincloud"],"exampleFix":"# before\nspacetime dev --server maincloud  # answered 'n' at sign-in\n# after\nspacetime login && spacetime dev --server maincloud","handlingStrategy":"validation","validationCode":"# Fail fast in scripts if no token for maincloud\nspacetime server list >/dev/null\nspacetime identity show --server maincloud >/dev/null 2>&1 || spacetime server login maincloud\nspacetime dev --server maincloud","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Authenticate before scripted dev runs against maincloud","Keep one known-good profile per machine; re-login after token rotation"],"tags":["cli","authentication","maincloud","spacetimedb"],"backgroundTag":"authentication-required","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}