juicedata/juicefs · error
failed to create current out dir %s: %v
Error message
failed to create current out dir %s: %v
What it means
`juicefs debug` creates a timestamped output directory under `--out-dir` via `os.MkdirAll`. This error is thrown when directory creation fails, wrapping the path and the underlying OS error (permission denied, path is a file, disk full, etc.).
Source
Thrown at cmd/debug.go:536
} else {
if inode != uint64(meta.RootInode) {
return fmt.Errorf("path %s is not a mount point", mp)
}
}
amp, err := filepath.Abs(mp)
if err != nil {
return fmt.Errorf("failed to get absolute path: %v", err)
}
timestamp := time.Now().Format("20060102150405")
prefix := strings.Trim(strings.Join(strings.Split(amp, "/"), "-"), "-")
if runtime.GOOS == "windows" {
prefix = strings.ReplaceAll(prefix, ":", "")
}
outDir := ctx.String("out-dir")
currDir := filepath.Join(outDir, fmt.Sprintf("%s-%s", prefix, timestamp))
if err := os.MkdirAll(currDir, os.ModePerm); err != nil {
return fmt.Errorf("failed to create current out dir %s: %v", currDir, err)
}
if err := collectSysInfo(ctx, currDir); err != nil {
logger.Errorf("Failed to collect system info: %v", err)
}
uid, pid, cmd, err := getCmdMount(amp)
logger.Infof("mount point:%q pid:%s uid:%s", amp, pid, uid)
if err != nil {
return fmt.Errorf("failed to get mount command: %v", err)
}
fmt.Printf("\nMount Command:\n%s\n\n", cmd)
requireRootPrivileges := false
if (uid == "0" || uid == "root") && os.Getuid() != 0 {
fmt.Println("Mount point is mounted by the root user, may ask for root privilege...")
requireRootPrivileges = true
}View on GitHub (pinned to c9a67b23e8)
Solutions
- Check/create the `--out-dir` and ensure it is writable by the current user: `mkdir -p <out-dir> && ls -ld <out-dir>`.
- If a path component is a file, remove/rename it or pick another out-dir.
- Free disk space if the wrapped error indicates ENOSPC.
- Run with appropriate privileges or choose an out-dir the user can write to (e.g. `$HOME/jfs-debug`).
Example fix
// before $ juicefs debug --out-dir /root/r /jfs failed to create current out dir ... // after $ mkdir -p ~/jfs-debug && juicefs debug --out-dir ~/jfs-debug /jfs
Defensive patterns
Strategy: validation
Validate before calling
outDir := flagOutDir
if fi, err := os.Stat(outDir); err != nil || !fi.IsDir() {
if err := os.MkdirAll(outDir, 0o755); err != nil {
return fmt.Errorf("out-dir %s unusable: %w", outDir, err)
}
}
if f, err := os.CreateTemp(outDir, ".wtest"); err != nil {
return fmt.Errorf("out-dir %s not writable: %w", outDir, err)
} else { f.Close(); os.Remove(f.Name()) } Type guard
null
Try / catch
if err := runDebug(mp); err != nil {
var perr *fs.PathError
if errors.As(err, &perr) && errors.Is(perr.Err, os.ErrPermission) {
// choose a writable out-dir or elevate
}
} Prevention
- Ensure --out-dir exists and is writable
- Don't point --out-dir at an existing file
- Check free disk space before collecting debug data
When it happens
Trigger: Running `juicefs debug` where the `--out-dir` (default `./`) does not exist, is not writable, a component of the path is a regular file, or the filesystem is out of space/inodes.
Common situations: Passing `--out-dir /root/reports` as a non-root user; `--out-dir` pointing at an existing file; running from a read-only directory; full disk during incident debugging.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- abs of %s: %s
- lookup inode for %s: %s
- %s already exists
- stat %s: %s
- the clone DST path should be at the same mount point as the
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/000744871d581071.
Report an issue: GitHub.