juicedata/juicefs · error

resolve path %s: %s

Error message

resolve path %s: %s

What it means

findSelfPath determines the absolute path of the running juicefs binary so the manager can ship it to workers. When os.Args[0] contains '/', it resolves it with filepath.Abs; this error wraps a failure of that resolution (rare; e.g. issues constructing the absolute path). Worker startup cannot proceed without the binary path.

Source

Thrown at pkg/sync/cluster.go:360

	if !strings.Contains(addr, ":") {
		addr += ":"
	}

	l, err := net.Listen("tcp", addr)
	if err != nil {
		return "", fmt.Errorf("listen: %s", err)
	}
	logger.Infof("Listen at %s", l.Addr())
	go func() { _ = http.Serve(l, mux) }()
	return l.Addr().String(), nil
}

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 {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Invoke juicefs via a normal absolute or relative path (e.g. /usr/local/bin/juicefs) so filepath.Abs can resolve it
  2. Check how the process is launched (scripts, containers) for a mangled argv[0]
  3. As a workaround, place the binary in PATH so findSelfPath uses the PATH search branch instead
Defensive patterns

Strategy: try-catch

Try / catch

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

Prevention

When it happens

Trigger: startManager (via prepareWorkerCommand) calls findSelfPath while os.Args[0] contains '/' and filepath.Abs(program) returns an error — practically only when the program name is malformed/empty beyond a separator or an unusual OS-level path resolution failure occurs.

Common situations: Launching the binary through exotic wrappers that mangle argv[0]; running with a manipulated os.Args; chroot environments where the path cannot be resolved.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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