clockworklabs/SpacetimeDB · error
Failed to get file_type for template file {}: {err:#?}
Error message
Failed to get file_type for template file {}: {err:#?} What it means
Build-time panic in crates/cli/build.rs: `dir_ent.file_type()` failed for an entry discovered while recursively listing a templates directory. Deciding whether to recurse (directory) or record (file) requires the entry's type; if the underlying stat call fails — dangling symlink, entry deleted between listing and stat, or I/O error — the enumeration panics rather than misclassifying the file.
Source
Thrown at crates/cli/build.rs:356
/// Get all the paths of files within `root_dir`,
/// transform them into paths relative to `repo_root`,
/// and insert them into `out`.
fn ls_recursively(root_dir: &Path, repo_root: &Path, out: &mut Vec<PathBuf>) {
for dir_ent in std::fs::read_dir(root_dir).unwrap_or_else(|err| {
panic!(
"Failed to read_dir from template directory {}: {err:#?}",
root_dir.display()
)
}) {
let dir_ent = dir_ent.unwrap_or_else(|err| {
panic!(
"Got error during read_dir from template directory {}: {err:#?}",
root_dir.display(),
)
});
let file_path = dir_ent.path();
let file_type = dir_ent.file_type().unwrap_or_else(|err| {
panic!(
"Failed to get file_type for template file {}: {err:#?}",
file_path.display(),
)
});
if file_type.is_dir() {
ls_recursively(&file_path, repo_root, out);
} else {
out.push(make_repo_root_relative(&file_path, repo_root));
}
}
}
/// Treat `relative_path` as a relative path within the repo root's templates directory
/// and transform it into an absolute, canonical path.
fn get_full_path_within_manifest_dir(relative_path: &Path, _manifest_dir: &Path) -> PathBuf {
let repo_root = get_repo_root();
let full_path = repo_root.join("templates").join(relative_path);
View on GitHub (pinned to 6dee26c6ef)
Solutions
- Locate unreadable entries: `find templates -xtype l -o ! -readable` and remove or repair them.
- Ensure nothing mutates templates/ during the build; re-run cargo afterwards.
- Check the mount health if templates live on FUSE/NFS — building from a local copy avoids it.
- Restore any deleted target of a symlink (`git checkout -- templates`) if the link is intentional.
Defensive patterns
Strategy: validation
Validate before calling
# Detect entries whose type cannot be determined (dangling symlinks): find templates -xtype l -o ! -readable
Prevention
- Commit real files, not symlinks, under templates/.
- Ensure build-user has read+execute on every templates subdirectory.
- Re-run builds after cleaning up broken links instead of ignoring transient stat failures.
When it happens
Trigger: A symlink inside templates/ whose target no longer exists; files being created/deleted by another process during the cargo build; permission or filesystem errors preventing stat of an entry.
Common situations: Broken symlinks committed or left behind in templates/; builds racing with git operations or generators; unusual filesystems (some FUSE mounts) that fail file_type for special entries.
Related errors
- Tried to read ${n} byte(s) at relative offset ${this.offset}
- Failed to read_dir from template directory {}: {err:#?}
- Got error during read_dir from template directory {}: {err:#
- Path {} is outside repo root {}
- Could not read skills directory at {}. Ensure skills/ exists
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/9533482af93d13e7.
Report an issue: GitHub.