{"record":{"id":"fff625699e60f330","repo":"clockworklabs/SpacetimeDB","slug":"found-err-count-disallowed-print-statement-s-t","errorCode":null,"errorMessage":"Found {err_count} disallowed print statement(s).\nThese will not be printed from SpacetimeDB modules.\nIf you need to print something, use the `log` crate\nand the `log::info!` macro instead.","messagePattern":"Found (.+?) disallowed print statement\\(s\\)\\.\nThese will not be printed from SpacetimeDB modules\\.\nIf you need to print something, use the `log` crate\nand the `log::info!` macro instead\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/rust.rs","lineNumber":68,"sourceCode":"                let file = fs::File::open(file.path())?;\n                for (idx, line) in io::BufReader::new(file).lines().enumerate() {\n                    let line = line?;\n                    let line_number = idx + 1;\n                    for disallowed in &[\"println!\", \"print!\", \"eprintln!\", \"eprint!\", \"dbg!\"] {\n                        if line.contains(disallowed) {\n                            if err_count == 0 {\n                                eprintln!(\"\\nDetected nonfunctional print statements:\\n\");\n                            }\n                            eprintln!(\"{printable_path}:{line_number}: {line}\");\n                            err_count += 1;\n                        }\n                    }\n                }\n            }\n        }\n        if err_count > 0 {\n            eprintln!();\n            anyhow::bail!(\n                \"Found {err_count} disallowed print statement(s).\\n\\\n                These will not be printed from SpacetimeDB modules.\\n\\\n                If you need to print something, use the `log` crate\\n\\\n                and the `log::info!` macro instead.\"\n            );\n        }\n    } else {\n        println!(\n            \"Warning: Skipping checks for nonfunctional print statements.\\n\\\n            If you have used builtin macros for printing, such as println!,\\n\\\n            your logs will not show up.\"\n        );\n    }\n\n    let mut args = if let Some(features) = features {\n        vec![format!(\"--features={}\", features.to_string_lossy())]\n    } else {\n        vec![]","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/rust.rs#L50-L86","documentation":"SpacetimeDB compiles Rust modules to WebAssembly and runs them in its own host, where the standard print macros (println!, print!, eprintln!, eprint!, dbg!) are nonfunctional -- nothing is printed anywhere. Before building, the CLI walks the module's lint directory, scans every .rs file line by line for these macro names, prints each offending file:line, and aborts the build. The `log` crate macros (log::info! etc.) are wired into the host and are the supported way to emit diagnostics.","triggerScenarios":"Running `spacetime build` or `spacetime publish` on a Rust module whose source files (under the lint dir, typically src/) contain the substring println!, print!, eprintln!, eprint!, or dbg! on any line. The scan is a plain substring match, so even commented-out code or a macro name inside a string literal is flagged.","commonSituations":"Porting an existing Rust crate (CLI, game server, library) into a SpacetimeDB module; leaving debug prints or a dbg!(x) in helper code during development; commented-out prints still matching the scanner.","solutions":["Replace every println!/print!/eprintln!/eprint!/dbg! in module source with log::info!, log::debug!, log::warn! or log::error! from the `log` crate","Make sure `log` is available (it is re-exported by the spacetimedb crate; `use spacetimedb::log;` also works)","Remove or rewrite commented-out code that mentions the macro names, since the scanner matches substrings even in comments","Re-run spacetime build to confirm the lint passes"],"exampleFix":"// before\nprintln!(\"Player {} joined\", name);\n\n// after\nlog::info!(\"Player {} joined\", name);","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# run before spacetime build\nif grep -RnE 'e?print(ln)?!|dbg!' --include='*.rs' src/; then\n  echo 'ERROR: print macros are nonfunctional in modules; use log::info!' >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use log::info!/log::debug! from the first line of module code, never println!","Deny the macros at compile time: add#![deny(clippy::print_stdout, clippy::dbg_macro)] to lib.rs","Run spacetime build in CI so the lint fires before a human sees it","Remember the scan is substring-based -- even commented-out println! trips it"],"tags":["rust","wasm","logging","build-lint","cli"],"backgroundTag":"print-not-supported-in-wasm","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}