{"record":{"id":"75e95b36bd9d71cb","repo":"juicedata/juicefs","slug":"failed-to-get-mount-command-v","errorCode":null,"errorMessage":"failed to get mount command: %v","messagePattern":"failed to get mount command: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug.go","lineNumber":546,"sourceCode":"\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}\n\n\tvar wg sync.WaitGroup\n\tif err := collectSpecialFile(ctx, amp, currDir, requireRootPrivileges, &wg); err != nil {\n\t\tlogger.Errorf(\"Failed to collect special file: %v\", err)\n\t}\n\n\tif err := collectLog(ctx, cmd, requireRootPrivileges, currDir, uid); err != nil {\n\t\tlogger.Errorf(\"Failed to collect log: %v\", err)\n\t}\n","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug.go#L528-L564","documentation":"After resolving the mount point, `juicefs debug` calls `getCmdMount(amp)` to find the mount process (uid, pid, command line). This error wraps any failure from that lookup — the underlying error comes from `ps` execution or from ambiguity/no-match in the process table scan.","triggerScenarios":"Running `juicefs debug <mp>` when `getCmdMount` fails: the `ps` command cannot execute, no matching mount process is found, or multiple candidate mount processes create ambiguity.","commonSituations":"Debugging on a system without `ps` or a restricted /proc; a FUSE mount whose process is not visible (different user/namespace); multiple nested JuiceFS mounts on the same path.","solutions":["Read the wrapped `%v` error to distinguish command failure from 'no mount command found' or 'more than one mount process'.","Verify the mount is visible: `ps -ef | grep juicefs mount`.","If multiple processes match, dismount stale/duplicate mounts and keep a single mount of the path.","On restricted environments, run as root so all processes are visible."],"exampleFix":"// before (duplicate mounts, ambiguous)\n$ juicefs debug /jfs\n// after (unmount duplicates first)\n$ sudo umount /jfs && sudo juicefs mount meta.db /jfs\n$ juicefs debug /jfs","handlingStrategy":"try-catch","validationCode":"out, err := exec.Command(\"ps\", \"-ef\").Output()\nif err != nil { return fmt.Errorf(\"ps unavailable: %w\", err) }\nmatches := 0\nfor _, l := range strings.Split(string(out), \"\\n\") {\n  if strings.Contains(l, \"mount\") && strings.Contains(l, mp) { matches++ }\n}\nif matches == 0 { return errors.New(\"no mount process visible\") }\nif matches > 1 { return errors.New(\"ambiguous mount processes\") }","typeGuard":"null","tryCatchPattern":"err := runDebug(mp)\nif err != nil && strings.Contains(err.Error(), \"failed to get mount command\") {\n    logger.Warn(\"mount process lookup failed; continuing with remaining debug info\")\n}","preventionTips":["Verify a single mount process serves the path before debugging","Avoid duplicate/stale mounts of the same path","Run in the same PID namespace as the mount process"],"tags":["cli","process","mount"],"backgroundTag":"command-not-found","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"}