wavetermdev/waveterm · error
getting file info: %w
Error message
getting file info: %w
What it means
If os.Stat fails with an error other than fs.ErrNotExist (permission denied, I/O error, too many symlinks, etc.), editorRun wraps it as "getting file info". This distinguishes general stat failures from the plain not-exist case.
Source
Thrown at cmd/wsh/cmd/wshcmd-editor.go:55
if len(args) == 0 {
OutputHelpMessage(cmd)
return fmt.Errorf("no arguments. wsh editor requires a file or URL as an argument argument")
}
if len(args) > 1 {
OutputHelpMessage(cmd)
return fmt.Errorf("too many arguments. wsh editor requires exactly one argument")
}
fileArg := args[0]
absFile, err := filepath.Abs(fileArg)
if err != nil {
return fmt.Errorf("getting absolute path: %w", err)
}
_, err = os.Stat(absFile)
if err == fs.ErrNotExist {
return fmt.Errorf("file does not exist: %q", absFile)
}
if err != nil {
return fmt.Errorf("getting file info: %w", err)
}
tabId := getTabIdFromEnv()
if tabId == "" {
return fmt.Errorf("no WAVETERM_TABID env var set")
}
wshCmd := wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: map[string]any{
waveobj.MetaKey_View: "preview",
waveobj.MetaKey_File: absFile,
waveobj.MetaKey_Edit: true,
},
},
Magnified: editMagnified,
Focused: true,View on GitHub (pinned to a4447c1563)
Solutions
- Check permissions on the file and each parent directory (`ls -ld`)
- Inspect the wrapped inner error for the exact errno
- Resolve symlink loops with `readlink -f`
- Ensure the volume/mount holding the file is available
Example fix
// before wsh editor /root/secret.txt # permission denied // after chmod o+rx /root && wsh editor /root/secret.txt # or use an accessible path
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(path); err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("cannot access %q: %v", path, err)
} Try / catch
if err := wsh.Editor(path); err != nil {
var perr *fs.PathError
if errors.As(err, &perr) {
log.Printf("stat failed on %s: %v", perr.Path, perr.Err)
// fix permissions/symlinks based on perr.Err
}
} Prevention
- Check directory traversal permissions (o+x) on parent dirs
- Avoid symlink loops; use readlink -f to normalize
- Keep target volumes mounted before running editor commands
When it happens
Trigger: os.Stat returning e.g. EACCES on a parent directory, ELOOP from symlink cycles, or device/IO errors while stating the path.
Common situations: File inside a directory the user cannot traverse; broken symlink loops; files on unmounted or failing volumes.
Related errors
- getting file info: %w
- accessing file %s: %w
- reading directory %s: %w
- reading file %s: %w
- error creating listener at %v: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/3634b903d6f8758b.
Report an issue: GitHub.