{"record":{"id":"ad64f12697872d52","repo":"juicedata/juicefs","slug":"can-t-find-path-for-s","errorCode":null,"errorMessage":"can't find path for %s","messagePattern":"can't find path for (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/cluster.go","lineNumber":372,"sourceCode":"\nfunc findSelfPath() (string, error) {\n\tprogram := os.Args[0]\n\tif strings.Contains(program, \"/\") {\n\t\tpath, err := filepath.Abs(program)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"resolve path %s: %s\", program, err)\n\t\t}\n\t\treturn path, nil\n\t}\n\tfor _, searchPath := range strings.Split(os.Getenv(\"PATH\"), \":\") {\n\t\tif searchPath != \"\" {\n\t\t\tp := filepath.Join(searchPath, program)\n\t\t\tif _, err := os.Stat(p); err == nil {\n\t\t\t\treturn p, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"can't find path for %s\", program)\n}\n\nfunc prepareWorkerCommand(host, address, path string, config *Config) ([]string, []byte, error) {\n\tworkerArgs := append([]string(nil), os.Args[1:]...)\n\tvar foundSource, foundDestination bool\n\tfor i, arg := range workerArgs {\n\t\tif arg == config.clusterSource {\n\t\t\tworkerArgs[i] = utils.RemovePassword(config.clusterSource)\n\t\t\tfoundSource = true\n\t\t}\n\t\tif arg == config.clusterDestination {\n\t\t\tworkerArgs[i] = utils.RemovePassword(config.clusterDestination)\n\t\t\tfoundDestination = true\n\t\t}\n\t}\n\tif !foundSource || !foundDestination {\n\t\treturn nil, nil, fmt.Errorf(\"can't locate source or destination in command arguments\")\n\t}","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/sync/cluster.go#L354-L390","documentation":"findSelfPath searches each PATH entry for the running program when os.Args[0] has no '/'. This error is returned if no directory in PATH contains an executable file named os.Args[0], so the manager cannot locate the juicefs binary to distribute to workers.","triggerScenarios":"juicefs started with a bare program name (no '/' in argv[0]) while the binary is not actually present in any PATH directory — e.g. invoked through a wrapper that changed cwd/PATH, or the binary was moved/deleted after the process started.","commonSituations":"Running juicefs via relative PATH lookups that later break; cron/systemd jobs with a minimal PATH that excludes the binary's directory; invoking through `env` or scripts that reset PATH; container images where PATH differs from the shell used to test.","solutions":["Start juicefs with an absolute path (e.g. /usr/local/bin/juicefs sync ...) so the PATH search is skipped","Add the binary's directory to PATH for the launching environment (cron/systemd/container)","Verify the binary exists and is executable in one of the PATH directories (command -v juicefs)"],"exampleFix":"// before (cron with default PATH)\njuicefs sync --worker w1 src dst\n// after\n/usr/local/bin/juicefs sync --worker w1 src dst","handlingStrategy":"fallback","validationCode":"// Verify the binary is discoverable before starting distributed sync\nif _, err := exec.LookPath(\"juicefs\"); err != nil {\n\treturn fmt.Errorf(\"juicefs not in PATH: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"path, err := findSelfPath()\nif err != nil {\n\tpath = \"/usr/local/bin/juicefs\" // known install location fallback\n}","preventionTips":["Start juicefs with an absolute path in cron/systemd/containers","Ensure PATH includes the binary's directory in the launching environment","Run `command -v juicefs` in the same environment that launches sync"],"tags":["filesystem","path","distributed-sync","env"],"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-14T05:17:10.506Z"}