{"record":{"id":"8fa5988da761ab72","repo":"clockworklabs/SpacetimeDB","slug":"module-bindings-path-exists-but-is-not-a-direct","errorCode":null,"errorMessage":"Module bindings path {} exists but is not a directory.","messagePattern":"Module bindings path (.+?) exists but is not a directory\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":583,"sourceCode":"                .and_then(|v| v.as_str())\n        });\n        if let Some(db_name) = db_to_persist\n            && let Some(path) = create_local_spacetime_config_if_missing(&project_dir, db_name)?\n        {\n            println!(\"{} Created {}\", \"✓\".green(), strip_verbatim_prefix(&path).display());\n        }\n    }\n\n    if !module_bindings_dir.exists() {\n        // Create the module bindings directory if it doesn't exist\n        std::fs::create_dir_all(&module_bindings_dir).with_context(|| {\n            format!(\n                \"Failed to create module bindings path {}\",\n                module_bindings_dir.display()\n            )\n        })?;\n    } else if !module_bindings_dir.is_dir() {\n        anyhow::bail!(\n            \"Module bindings path {} exists but is not a directory.\",\n            module_bindings_path.display()\n        );\n    }\n\n    // Check if we need to login to maincloud\n    // Either because --server maincloud was provided, or because any of the publish configs use maincloud\n    let needs_maincloud_login = resolved_server == \"maincloud\"\n        || spacetime_config\n            .map(|c| {\n                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                })","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dev.rs#L565-L601","documentation":"`spacetime dev` validates the module bindings output location: it will create the directory if missing, but if the path exists AND is a regular file (or symlink to one) it bails, because generating bindings requires a directory. The message interpolates the user-supplied relative `--module-bindings-path`.","triggerScenarios":"`--module-bindings-path` (or the config equivalent) resolves to an existing file, e.g. a stray `generated` file, a placeholder, or a path where a previous tool wrote a file of the same name.","commonSituations":"A file created at the intended directory path (touch/echo redirected wrongly); residue from other generators; case-sensitivity or trailing-slash confusion in the path; Windows path quirks.","solutions":["Inspect the path: `ls -la <project>/<bindings-path>` — if it is a file, decide whether to keep it","Rename or delete the conflicting file, then re-run `spacetime dev` (it will create the directory)","Choose a different directory name for bindings: `--module-bindings-path some/other/dir`"],"exampleFix":"# before: ./generated exists as a file\nspacetime dev --module-bindings-path generated\n# after\nrm ./generated && spacetime dev --module-bindings-path generated","handlingStrategy":"type-guard","validationCode":"# Ensure the bindings path is absent or a directory\nBP=generated\nif [ -e \"$BP\" ] && [ ! -d \"$BP\" ]; then echo \"$BP is a file\"; exit 1; fi","typeGuard":"use std::path::Path;\nfn is_usable_bindings_dir(p: &Path) -> bool {\n    !p.exists() || p.is_dir()\n}","tryCatchPattern":null,"preventionTips":["Never create placeholder files at directory paths","Prefer dedicated subdirectories (e.g. src/generated/) unlikely to collide with files"],"tags":["cli","filesystem","path","spacetimedb"],"backgroundTag":"path-conflicts-with-file","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}