clockworklabs/SpacetimeDB · info · anyhow::Error

Publish aborted by user.

Error message

Publish aborted by user.

What it means

Before uploading, `spacetime publish` extracts the server address from the resolved database host URL. If it is anything other than `localhost` or `127.0.0.1`, the CLI prints 'You are about to publish to a non-local server' and prompts y/N. `y_or_n` returns true only for literal `y`/`yes` (or when a force/`--yes` flag short-circuits it); anything else — including EOF on a closed stdin — bails with this error.

Source

Thrown at crates/cli/src/subcommands/publish.rs:576

                path_to_project
                    .as_ref()
                    .expect("path_to_project must exist when publishing from source"),
                &build_options,
                native_aot,
                dotnet_version,
            )
            .await?
        };
        let program_bytes = fs::read(path_to_program)?;

        let server_address = {
            let url = Url::parse(&database_host)?;
            url.host_str().unwrap_or("<default>").to_string()
        };
        if server_address != "localhost" && server_address != "127.0.0.1" {
            println!("You are about to publish to a non-local server: {server_address}");
            if !y_or_n(yes.publish_to_remote, "Are you sure you want to proceed?")? {
                anyhow::bail!("Publish aborted by user.");
            }
        }

        println!(
            "Uploading to {} => {}",
            server.unwrap_or(config.default_server_name().unwrap_or("<default>")),
            database_host
        );

        let client = reqwest::Client::new();
        // If a name was given, ensure to percent-encode it.
        // We also use PUT with a name or identity, and POST otherwise.
        let mut builder = if let Some(name_or_identity) = name_or_identity {
            let encode_set = const { &percent_encoding::NON_ALPHANUMERIC.remove(b'_').remove(b'-') };
            let domain = percent_encoding::percent_encode(name_or_identity.as_bytes(), encode_set);
            let mut builder = client.put(format!("{database_host}/v1/database/{domain}"));

            // note that this only happens in the case where we've passed a `name_or_identity`, but that's required if we pass `--clear-database`.

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Re-run the command and answer `y` at the prompt if the remote target is intended
  2. Pass the global `--yes` flag (maps to `yes.publish_to_remote`) to auto-confirm remote publishing in scripts
  3. Verify you are targeting the intended server with `spacetime server list` / `spacetime server ping`, and switch back to localhost if you meant local development
  4. Ensure stdin is a TTY or supply `--yes` when automating, since EOF counts as 'no'

Example fix

# before
spacetime publish -s https://server.spacetimedb.com mydb   # prompt -> aborted
# after
spacetime publish -s https://server.spacetimedb.com --yes mydb
Defensive patterns

Strategy: validation

Validate before calling

# Before publishing, resolve and check the host yourself
url="$(spacetime server list 2>/dev/null | awk '/\*/{print $2}')"  # or however you capture it
case "$url" in *localhost*|*127.0.0.1*) ;; *) echo "remote target: $url" ;; esac

Prevention

When it happens

Trigger: Running `spacetime publish` (or `spacetime generate`/deploy flows that reuse it) while the active server URL points at a remote host (e.g. maincloud/testnet), then answering 'n', pressing Enter on the empty default, or running non-interactively so stdin returns EOF at the prompt.

Common situations: Switching `spacetime server set-default` to a remote server and forgetting the confirmation now appears; CI/scripts invoking publish without `--yes` so the prompt reads EOF and aborts; genuinely intending local dev but the URL uses a LAN IP or hostname instead of localhost.

Related errors


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