{"record":{"id":"33aa7e4f88f25671","repo":"juicedata/juicefs","slug":"stat-s-s","errorCode":null,"errorMessage":"stat %s: %s","messagePattern":"stat (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/clone.go","lineNumber":87,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"abs of %s: %s\", srcPath, err)\n\t}\n\tsrcIno, err := utils.GetFileInode(srcPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"lookup inode for %s: %s\", srcPath, err)\n\t}\n\tsrcParentIno, err := utils.GetFileInode(filepath.Dir(srcAbsPath))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"lookup inode for %s: %s\", filepath.Dir(srcAbsPath), err)\n\t}\n\tdst := ctx.Args().Get(1)\n\tif strings.HasSuffix(dst, string(filepath.Separator)) {\n\t\tdst = filepath.Join(dst, filepath.Base(srcPath))\n\t}\n\tif _, err := os.Stat(dst); err == nil {\n\t\treturn fmt.Errorf(\"%s already exists\", dst)\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"stat %s: %s\", dst, err)\n\t}\n\tdstAbsPath, err := filepath.Abs(dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"abs of %s: %s\", dst, err)\n\t}\n\n\tsrcMp, err := findMountpoint(srcAbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdstMp, err := findMountpoint(filepath.Dir(dstAbsPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif srcMp != dstMp {\n\t\treturn fmt.Errorf(\"the clone DST path should be at the same mount point as the SRC path\")\n\t}\n\tif strings.HasPrefix(dstAbsPath, path.Clean(srcAbsPath)+\"/\") {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/clone.go#L69-L105","documentation":"The `juicefs clone` command checks whether the destination path already exists by calling os.Stat. If Stat fails with an error that is NOT 'file does not exist' (e.g. permission denied on a parent directory, I/O error, or the path component is not a directory), the command cannot safely determine DST availability and wraps the raw error as \"stat %s: %s\".","triggerScenarios":"Running `juicefs clone SRC DST` where os.Stat(DST) fails with an error other than ENOENT — e.g. a parent directory of DST lacks execute/search permission (EACCES), a path component is not a directory (ENOTDIR), the filesystem is inaccessible, or a symlink loop exists.","commonSituations":"DST parent directory owned by another user without +x permission; DST contains a non-directory component (e.g. cloning to /mnt/jfs/file1/sub/file when file1 is a regular file); stale NFS/FUSE mount returning I/O errors; SELinux/AppArmor blocking stat on the target.","solutions":["Check permissions on every existing component of DST (ls -ld on each parent) and grant search (+x) permission for the running user","Verify each prefix of DST is a directory: run `stat` on each path component and fix or remove the non-directory component","Check for symlink loops (`namei -l DST`) and fix the symlink","If the mount is broken, remount the JuiceFS volume (`juicefs mount ...`) and retry","As a workaround, pick a DST path in a directory you can stat and that does not exist yet"],"exampleFix":"// before\njuicefs clone /mnt/jfs/a /mnt/jfs/otheruser/dir/x   # EACCES\n// after\nsudo chmod o+x /mnt/jfs/otheruser/dir\njuicefs clone /mnt/jfs/a /mnt/jfs/otheruser/dir/x","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(dst); err != nil && !os.IsNotExist(err) {\n    return fmt.Errorf(\"cannot stat destination %s: %w\", dst, err)\n}","typeGuard":null,"tryCatchPattern":"err := sh.Run(\"juicefs\", \"clone\", src, dst)\nif strings.HasPrefix(err.Error(), \"stat \") {\n    // inspect DST path components: permissions / ENOTDIR\n}","preventionTips":["Stat-test the DST path in a preflight script before invoking clone","Keep DST parents world-traversable or run clone as the directory owner","Avoid DST paths containing regular-file components","Check `namei -l DST` when paths involve multiple users or symlink chains"],"tags":["cli","filesystem","stat","path-resolution"],"backgroundTag":"file-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}