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
- Restart websocketd from a valid working directory (cd to an existing dir first)
- Check that the process's cwd exists: `ls /proc/<pid>/cwd` or `pwd` in the launching shell
- 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
- Launch from a stable working directory (set WorkingDirectory= in systemd)
- Pass absolute --dir values
- Avoid deleting directories a running service still uses; move-then-delete
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
- unable to locate specified COMMAND '%s' in OS path
- could not find your script dir '%s'
- your %s '%s' is not pointing to an accessible directory
- --socketmode %q is not an octal permission mode (e.g. 0700)
- --socketmode %q has bits beyond permission bits (keep it wit
AI-assisted analysis of joewalnes/websocketd@7a8683dc7f (2026-09-03).
Data as JSON: /api/errors/e664e0c34662f501.
Report an issue: GitHub.