juicedata/juicefs · error

can't find path for %s

Error message

can't find path for %s

What it means

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.

Source

Thrown at pkg/sync/cluster.go:372

func findSelfPath() (string, error) {
	program := os.Args[0]
	if strings.Contains(program, "/") {
		path, err := filepath.Abs(program)
		if err != nil {
			return "", fmt.Errorf("resolve path %s: %s", program, err)
		}
		return path, nil
	}
	for _, searchPath := range strings.Split(os.Getenv("PATH"), ":") {
		if searchPath != "" {
			p := filepath.Join(searchPath, program)
			if _, err := os.Stat(p); err == nil {
				return p, nil
			}
		}
	}
	return "", fmt.Errorf("can't find path for %s", program)
}

func prepareWorkerCommand(host, address, path string, config *Config) ([]string, []byte, error) {
	workerArgs := append([]string(nil), os.Args[1:]...)
	var foundSource, foundDestination bool
	for i, arg := range workerArgs {
		if arg == config.clusterSource {
			workerArgs[i] = utils.RemovePassword(config.clusterSource)
			foundSource = true
		}
		if arg == config.clusterDestination {
			workerArgs[i] = utils.RemovePassword(config.clusterDestination)
			foundDestination = true
		}
	}
	if !foundSource || !foundDestination {
		return nil, nil, fmt.Errorf("can't locate source or destination in command arguments")
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Start juicefs with an absolute path (e.g. /usr/local/bin/juicefs sync ...) so the PATH search is skipped
  2. Add the binary's directory to PATH for the launching environment (cron/systemd/container)
  3. Verify the binary exists and is executable in one of the PATH directories (command -v juicefs)

Example fix

// before (cron with default PATH)
juicefs sync --worker w1 src dst
// after
/usr/local/bin/juicefs sync --worker w1 src dst
Defensive patterns

Strategy: fallback

Validate before calling

// Verify the binary is discoverable before starting distributed sync
if _, err := exec.LookPath("juicefs"); err != nil {
	return fmt.Errorf("juicefs not in PATH: %w", err)
}

Try / catch

path, err := findSelfPath()
if err != nil {
	path = "/usr/local/bin/juicefs" // known install location fallback
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/ad64f12697872d52. Report an issue: GitHub.