{"record":{"id":"4374b97ee2931ae0","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-read-directory","errorCode":null,"errorMessage":"Failed to read directory {}: {}","messagePattern":"Failed to read directory (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":274,"sourceCode":"    None\n}\n\npub fn detect_module_language(path_to_module: &Path) -> anyhow::Result<ModuleLanguage> {\n    // TODO: Possible add a config file durlng spacetime init with the language\n    if !path_to_module.exists() {\n        anyhow::bail!(\n            \"Module directory does not exist: '{}'. \\\n             Check your --module-path flag or the module-path setting in spacetime.json.\",\n            path_to_module.display()\n        );\n    }\n    // check for Cargo.toml\n    if path_to_module.join(\"Cargo.toml\").exists() {\n        Ok(ModuleLanguage::Rust)\n    } else if path_to_module.is_dir()\n        && path_to_module\n            .read_dir()\n            .map_err(|e| anyhow::anyhow!(\"Failed to read directory {}: {}\", path_to_module.display(), e))?\n            .flatten()\n            .any(|entry| entry.path().extension() == Some(\"csproj\".as_ref()))\n    {\n        Ok(ModuleLanguage::Csharp)\n    } else if path_to_module.join(\"package.json\").exists() {\n        Ok(ModuleLanguage::Javascript)\n    } else if path_to_module.join(\"CMakeLists.txt\").exists() {\n        Ok(ModuleLanguage::Cpp)\n    } else {\n        anyhow::bail!(\"Could not detect the language of the module. Are you in a SpacetimeDB project directory?\")\n    }\n}\n\npub fn url_to_host_and_protocol(url: &str) -> anyhow::Result<(&str, &str)> {\n    if contains_protocol(url) {\n        let protocol = url.split(\"://\").next().unwrap();\n        let host = url.split(\"://\").last().unwrap();\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/util.rs#L256-L292","documentation":"Raised while detecting a C# module: after confirming the path is a directory, the CLI calls std::fs::read_dir to scan for *.csproj entries and the OS-level call fails. The message includes the failing directory and the underlying io::Error. This is an environment or permissions problem, not a project-structure problem.","triggerScenarios":"read_dir returns EACCES because the current user lacks read/execute permission on the module directory; the path is a symlink loop or the entry vanished between the is_dir check and the read; an OS-level I/O error from a flaky NFS/WSL/network mount.","commonSituations":"Module directory created by root or another user; Docker bind-volume permission mismatch; directory on a dropped network mount; file locking by antivirus or another process on Windows.","solutions":["Check permissions: `ls -la <module-path>` and grant read access (`chmod +rX` or `chown -R $(whoami) <module-path>`).","Verify the path is a real directory and not a broken symlink: `stat <module-path>`.","If the project is on a network or WSL mount that is flaking, copy it to local disk and retry.","Re-run the CLI after fixing ownership or remounting the volume."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# fail early if the CLI cannot list the module directory\nls \"$MODULE_PATH\" >/dev/null 2>&1 || { echo \"cannot read $MODULE_PATH — check permissions/mount\" >&2; exit 1; }\nspacetime build --module-path \"$MODULE_PATH\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the CI user owns the module directory.","Avoid network mounts for build inputs when possible.","Check `stat <module-path>` in setup scripts to catch broken symlinks."],"tags":["spacetimedb","cli","io","permissions","csharp"],"backgroundTag":"directory-read-permission-denied","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}