{"record":{"id":"000744871d581071","repo":"juicedata/juicefs","slug":"failed-to-create-current-out-dir-s-v","errorCode":null,"errorMessage":"failed to create current out dir %s: %v","messagePattern":"failed to create current out dir (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug.go","lineNumber":536,"sourceCode":"\t} else {\n\t\tif inode != uint64(meta.RootInode) {\n\t\t\treturn fmt.Errorf(\"path %s is not a mount point\", mp)\n\t\t}\n\t}\n\n\tamp, err := filepath.Abs(mp)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get absolute path: %v\", err)\n\t}\n\ttimestamp := time.Now().Format(\"20060102150405\")\n\tprefix := strings.Trim(strings.Join(strings.Split(amp, \"/\"), \"-\"), \"-\")\n\tif runtime.GOOS == \"windows\" {\n\t\tprefix = strings.ReplaceAll(prefix, \":\", \"\")\n\t}\n\toutDir := ctx.String(\"out-dir\")\n\tcurrDir := filepath.Join(outDir, fmt.Sprintf(\"%s-%s\", prefix, timestamp))\n\tif err := os.MkdirAll(currDir, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"failed to create current out dir %s: %v\", currDir, err)\n\t}\n\n\tif err := collectSysInfo(ctx, currDir); err != nil {\n\t\tlogger.Errorf(\"Failed to collect system info: %v\", err)\n\t}\n\n\tuid, pid, cmd, err := getCmdMount(amp)\n\tlogger.Infof(\"mount point:%q pid:%s uid:%s\", amp, pid, uid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get mount command: %v\", err)\n\t}\n\tfmt.Printf(\"\\nMount Command:\\n%s\\n\\n\", cmd)\n\n\trequireRootPrivileges := false\n\tif (uid == \"0\" || uid == \"root\") && os.Getuid() != 0 {\n\t\tfmt.Println(\"Mount point is mounted by the root user, may ask for root privilege...\")\n\t\trequireRootPrivileges = true\n\t}","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug.go#L518-L554","documentation":"`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.).","triggerScenarios":"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.","commonSituations":"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.","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`)."],"exampleFix":"// before\n$ juicefs debug --out-dir /root/r /jfs\nfailed to create current out dir ...\n// after\n$ mkdir -p ~/jfs-debug && juicefs debug --out-dir ~/jfs-debug /jfs","handlingStrategy":"validation","validationCode":"outDir := flagOutDir\nif fi, err := os.Stat(outDir); err != nil || !fi.IsDir() {\n  if err := os.MkdirAll(outDir, 0o755); err != nil {\n    return fmt.Errorf(\"out-dir %s unusable: %w\", outDir, err)\n  }\n}\nif f, err := os.CreateTemp(outDir, \".wtest\"); err != nil {\n  return fmt.Errorf(\"out-dir %s not writable: %w\", outDir, err)\n} else { f.Close(); os.Remove(f.Name()) }","typeGuard":"null","tryCatchPattern":"if err := runDebug(mp); err != nil {\n  var perr *fs.PathError\n  if errors.As(err, &perr) && errors.Is(perr.Err, os.ErrPermission) {\n    // choose a writable out-dir or elevate\n  }\n}","preventionTips":["Ensure --out-dir exists and is writable","Don't point --out-dir at an existing file","Check free disk space before collecting debug data"],"tags":["cli","filesystem","mkdir"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}