joewalnes/websocketd · error

could not resolve absolute path to dir '%s'

Error message

could not resolve absolute path to dir '%s'

What it means

resolveScriptDir turns the --dir value into an absolute path with filepath.Abs; if that fails (Abs only errors when it cannot determine the current working directory), the CLI returns this error. It is a rare, low-level path-resolution failure distinct from 'directory does not exist'.

Source

Thrown at config.go:219

			return "", nil, fmt.Errorf("ambiguous: provided COMMAND and --dir argument, please only specify one")
		}
		path, lookErr := exec.LookPath(args[0])
		if lookErr != nil {
			return "", nil, fmt.Errorf("unable to locate specified COMMAND '%s' in OS path", args[0])
		}
		return path, args[1:], nil
	}
	return "", nil, nil
}

// resolveScriptDir validates and resolves the script directory path.
func resolveScriptDir(dir string) (string, error) {
	if dir == "" {
		return "", nil
	}
	absDir, err := filepath.Abs(dir)
	if err != nil {
		return "", fmt.Errorf("could not resolve absolute path to dir '%s'", dir)
	}
	inf, err := os.Stat(absDir)
	if err != nil {
		return "", fmt.Errorf("could not find your script dir '%s'", dir)
	}
	if !inf.IsDir() {
		return "", fmt.Errorf("did you mean to specify COMMAND instead of --dir '%s'?", dir)
	}
	return absDir, nil
}

// validateDir checks that a directory path exists and is a directory.
func validateDir(dir, label string) error {
	if dir == "" {
		return nil
	}
	inf, err := os.Stat(dir)
	if err != nil || !inf.IsDir() {

View on GitHub (pinned to 7a8683dc7f)

Solutions

  1. Restart websocketd from a valid working directory (cd to an existing dir first)
  2. Check that the process's cwd exists: `ls /proc/<pid>/cwd` or `pwd` in the launching shell
  3. Pass an absolute --dir value so only the cwd lookup, not the user path, is at fault — if it still fails, the cwd itself is broken

Example fix

// before (launched from a deleted directory)
websocketd --dir=scripts
// after
cd /srv/myapp && websocketd --dir=/srv/myapp/scripts
Defensive patterns

Strategy: validation

Validate before calling

wd, err := os.Getwd()
if err != nil {
	log.Fatalf("working directory unusable: %v", err)
}
if _, err := os.Stat(wd); err != nil {
	log.Fatal("cwd deleted; restart from a valid directory")
}

Try / catch

out, err := exec.Command("websocketd", "--dir=scripts").CombinedOutput()
if err != nil && strings.Contains(string(out), "could not resolve absolute path") {
	// restart process from a valid cwd before retrying
}

Prevention

When it happens

Trigger: Launching websocketd after the process's working directory has been deleted or is otherwise unstatable (e.g. removed from under a long-lived supervisor, or a container cwd pointing at a deleted volume path).

Common situations: Systemd/supervisor setups where the WorkingDirectory was removed; running from a deleted mount point; chroot or sandbox environments with an unset/invalid cwd.

Related errors


AI-assisted analysis of joewalnes/websocketd@7a8683dc7f (2026-09-03). Data as JSON: /api/errors/e664e0c34662f501. Report an issue: GitHub.