{"record":{"id":"709491eef9459a63","repo":"clockworklabs/SpacetimeDB","slug":"for-some-reason-your-project-has-both-a-bin-and","errorCode":null,"errorMessage":"For some reason, your project has both a `bin` and a `bin~` folder.\nI don't know which to use, so please delete both and rerun this command so that we can see which is up-to-date.","messagePattern":"For some reason, your project has both a `bin` and a `bin~` folder\\.\nI don't know which to use, so please delete both and rerun this command so that we can see which is up-to-date\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/csharp.rs","lineNumber":463,"sourceCode":"        )),\n        // NativeAOT-LLVM outputs to 'native' subdirectory instead of 'publish'\n        project_path.join(format!(\n            \"bin/{config_name}/{target_framework}/wasi-wasm/{subdir}/StdbModule.wasm\"\n        )),\n        project_path.join(format!(\n            \"bin~/{config_name}/{target_framework}/wasi-wasm/{subdir}/StdbModule.wasm\"\n        )),\n        // Also check for raw wasm output without wasi-wasm RID folder (NativeAOT-LLVM sometimes does this)\n        project_path.join(format!(\"bin/{config_name}/{target_framework}/native/StdbModule.wasm\")),\n        project_path.join(format!(\"bin~/{config_name}/{target_framework}/native/StdbModule.wasm\")),\n    ];\n    // Check if both bin and bin~ variants exist for the same output path (indicates a conflict)\n    for i in (0..possible_output_paths.len()).step_by(2) {\n        if i + 1 < possible_output_paths.len() {\n            let bin_path = &possible_output_paths[i];\n            let bin_tilde_path = &possible_output_paths[i + 1];\n            if bin_path.exists() && bin_tilde_path.exists() {\n                anyhow::bail!(concat!(\n                    \"For some reason, your project has both a `bin` and a `bin~` folder.\\n\",\n                    \"I don't know which to use, so please delete both and rerun this command so that we can see which is up-to-date.\"\n                ));\n            }\n        }\n    }\n    for output_path in &possible_output_paths {\n        if output_path.exists() {\n            return Ok(output_path.clone());\n        }\n    }\n\n    // Diagnostic: list what we expected and what actually exists in the output directories\n    eprintln!(\"Build path: {build_path:?}, target_framework: {target_framework}, subdir: {subdir}\");\n    eprintln!(\"Expected output in one of:\");\n    for p in &possible_output_paths {\n        eprintln!(\"  {}\", p.display());\n    }","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/9e0d92412ff2248f401a8ad12d535f2b5ac30912/crates/cli/src/tasks/csharp.rs#L445-L481","documentation":"Expected C# output locations come in bin/ and bin~ pairs (bin~ is a rename/backup some tooling produces). If both variants of the same output path exist after a successful publish, the CLI cannot tell which is current and aborts instead of guessing which StdbModule.wasm to upload.","triggerScenarios":"`spacetime build` succeeds but both e.g. bin/Release/net8.0/wasi-wasm/.../StdbModule.wasm and its bin~ twin exist -- typically after an interrupted build, or a watcher/backup tool renaming bin to bin~ between builds.","commonSituations":"Interrupted or concurrent builds; editors/antivirus/sync tools renaming directories; repeatedly switching between JIT and AOT build modes in the same tree.","solutions":["Delete both bin and bin~ (and obj, obj~ while at it), then re-run the build/publish.","If it recurs, find what keeps creating bin~ (sync/backup tool) and exclude the project directory from it."],"exampleFix":"# before\nspacetime build\n# after\nrm -rf bin bin~ obj obj~\nspacetime build","handlingStrategy":"validation","validationCode":"# Pre-build hygiene: never enter a build with split bin folders\n[ ! -d bin ] || [ ! -d bin~ ] || { echo \"both bin and bin~ present; cleaning\" >&2; rm -rf bin bin~; }\nspacetime build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clean bin/bin~ between CI builds (or build in fresh checkouts).","Identify and configure tools that rename bin to bin~ (backup/sync/AV) to skip the project.","Treat repeated recurrence as an environment problem, not a CLI problem."],"tags":["csharp","build-artifacts","bin-directory","conflict"],"backgroundTag":"conflicting-build-artifacts","analyzedSha":"9e0d92412ff2248f401a8ad12d535f2b5ac30912","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}