yorukot/superfile · error
cannot access source path %s: %w
Error message
cannot access source path %s: %w
What it means
validateCompressOperation wraps an os.Stat error that is NOT 'not exist' for a compression source — meaning the path exists but cannot be accessed (permission denied on a parent dir, I/O error, or a broken path component). The original error is preserved with %w.
Source
Thrown at src/internal/file_operations_compress.go:28
"path/filepath"
"strings"
"time"
tea "charm.land/bubbletea/v2"
"github.com/yorukot/superfile/src/internal/ui/notify"
"github.com/yorukot/superfile/src/internal/ui/processbar"
)
func validateCompressOperation(sources []string) (int, error) {
totalFiles := 0
for _, src := range sources {
stat, err := os.Stat(src)
if os.IsNotExist(err) {
return 0, fmt.Errorf("source path does not exist: %s", src)
}
if err != nil {
return 0, fmt.Errorf("cannot access source path %s: %w", src, err)
}
if !stat.IsDir() {
if err = checkFileReadable(src); err != nil {
slog.Error("the file is not readable", "error", err)
return 0, fmt.Errorf("the file is not readable: %s", err.Error())
}
}
count, err := countReadableFiles(src)
if err != nil {
slog.Error("Error while zip file count files ", "error", err)
return 0, fmt.Errorf("error while counting files for %s: %s", src, err.Error())
}
totalFiles += count
}
return totalFiles, nil
}
func (m *model) getCompressSelectedFilesCmd() tea.Cmd {View on GitHub (pinned to b72f550bc6)
Solutions
- Inspect the wrapped cause with errors.As(*fs.PathError) to see which syscall/errno failed.
- Add x (traverse) permission on parent directories: chmod +x on each ancestor of the source.
- Remount stale network shares or fix broken symlinks in the path.
- Run as a user with sufficient rights, or exclude inaccessible sources from the selection.
Example fix
// before
var pe *fs.PathError
if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrPermission) {
return fmt.Errorf("cannot access %s: check directory execute permissions", pe.Path)
} Defensive patterns
Strategy: validation
Validate before calling
for _, s := range sources {
if _, err := os.Stat(s); err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("source %s inaccessible: %w", s, err)
}
} Try / catch
if err := ops.ZipSources(sources, target); err != nil {
var pe *fs.PathError
if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrPermission) {
return fmt.Errorf("add execute permission on %s parent dirs", pe.Path)
}
return err
} Prevention
- Keep traverse (x) permission on all ancestor directories of sources.
- Fix stale NFS/network mounts before compressing from them.
- Check for broken symlinks in source paths.
When it happens
Trigger: os.Stat fails with EACCES (no execute permission on a parent directory), EIO on flaky storage, or symlink loops / other stat errors on a source passed to zipSources.
Common situations: Compressing files under a directory the user can traverse only partially; NFS/network mounts returning stale handles; directories with restrictive ACLs.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- the file is not readable: %s
- failed to create destination file: %w
- source path does not exist: %s
- error while counting files for %s: %s
- failed to get absolute path of the first path: %w
AI-assisted analysis of yorukot/superfile@b72f550bc6 (2026-09-01).
Data as JSON: /api/errors/b543f6182d51677a.
Report an issue: GitHub.