gastownhall/beads · error
failed to inspect opened directory %s: %w
Error message
failed to inspect opened directory %s: %w
What it means
After opening the directory securely, the code calls dir.Stat() on the handle to verify the opened target. This error wraps a failure of that stat — the opened directory handle could not be inspected, so the safety comparison against the original Lstat info cannot proceed.
Source
Thrown at internal/config/permissions.go:75
return false, fmt.Errorf("refusing to chmod %s: path is a symbolic link", path)
}
if !info.IsDir() {
return false, fmt.Errorf("refusing to chmod %s: path is not a directory", path)
}
perm := info.Mode().Perm()
if perm&0077 == 0 {
return false, nil // no group or world-accessible bits
}
dir, err := openDir(path)
if err != nil {
return false, fmt.Errorf("failed to open %s securely: %w", path, err)
}
defer func() { _ = dir.Close() }()
openedInfo, err := dir.Stat()
if err != nil {
return false, fmt.Errorf("failed to inspect opened directory %s: %w", path, err)
}
if !openedInfo.IsDir() || !os.SameFile(info, openedInfo) {
return false, fmt.Errorf("refusing to chmod %s: path changed during permission repair", path)
}
if err := dir.Chmod(BeadsDirPerm); err != nil {
return false, fmt.Errorf("failed to chmod %s to %04o: %w", path, BeadsDirPerm, err)
}
return true, nil
}
View on GitHub (pinned to 71377f2769)
Solutions
- Re-run after checking system resource limits (ulimit -n) for fd exhaustion.
- Retry the permission fix; the failure is usually transient.
- As a fallback, chmod the directory directly from the shell: chmod 700 <path>.
Defensive patterns
Strategy: retry
Try / catch
changed, err := config.FixBeadsDirPermissions(beadsDir)
if err != nil && strings.Contains(err.Error(), "failed to inspect opened directory") {
// usually transient (fd pressure / fs hiccup): retry once after freeing resources
runtime.GC()
changed, err = config.FixBeadsDirPermissions(beadsDir)
} Prevention
- Watch for fd leaks in long-running processes (ulimit -n).
- Retry transient stat failures before surfacing to users.
When it happens
Trigger: Calling FixBeadsDirPermissions where fstat on the opened directory descriptor fails — extremely rare; typically caused by the descriptor becoming invalid (close racing), fd exhaustion, or filesystem errors on exotic mounts.
Common situations: EMFILE/ENFILE (file descriptor table exhausted) so the handle is in a bad state; kernel or FUSE errors; heavily sandboxed environments blocking fstat.
Related errors
- failed to open %s securely: %w
- dolt path is not executable
- failed to create backup directory: %w
- failed to create temp file: %w
- create beads directory: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/7fc7d4d27f1d38d8.
Report an issue: GitHub.