joewalnes/websocketd · error
could not find your script dir '%s'
Error message
could not find your script dir '%s'
What it means
resolveScriptDir stats the absolutized --dir path; when os.Stat fails (typically ENOENT), the CLI reports it could not find the script directory. This is the standard 'you passed a --dir that does not exist' failure and prevents starting a server that would have nothing valid to serve.
Source
Thrown at config.go:223
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() {
return fmt.Errorf("your %s '%s' is not pointing to an accessible directory", label, dir)
}
return nil
}View on GitHub (pinned to 7a8683dc7f)
Solutions
- Verify the directory exists at the exact path: `ls -ld <dir>`
- Use an absolute path in --dir to remove cwd dependence
- Fix the deployment (volume mount, systemd WorkingDirectory=) so the directory is present at startup
Example fix
// before websocketd --dir=./scriptz --port=8080 // after websocketd --dir=/srv/app/scripts --port=8080
Defensive patterns
Strategy: validation
Validate before calling
dir := "/srv/app/scripts"
if inf, err := os.Stat(dir); err != nil || !inf.IsDir() {
log.Fatalf("script dir missing: %s", dir)
}
exec.Command("websocketd", "--dir="+dir, "--port=8080").Run() Try / catch
out, err := exec.Command("websocketd", "--dir="+dir).CombinedOutput()
if err != nil && strings.Contains(string(out), "could not find your script dir") {
log.Fatalf("fix --dir value %q: does not exist", dir)
} Prevention
- Use absolute paths in service definitions
- Verify volume mounts exist before starting containers
- Check deploy scripts for typos with `ls -ld "$DIR"` first
- Set WorkingDirectory explicitly when using relative paths
When it happens
Trigger: `websocketd --dir=./scriptz ...` (typo); --dir pointing at a path deleted or renamed before startup; relative --dir resolved against a different cwd than the developer assumed (e.g. systemd unit with unexpected WorkingDirectory).
Common situations: Typos in deploy scripts; containers where the volume mounting the scripts dir is missing; packaging changes that moved the scripts directory; relative paths breaking when the service manager sets a different cwd.
Related errors
- could not resolve absolute path to 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
- --socketmode 0 would make the socket unusable; pick a mode l
AI-assisted analysis of joewalnes/websocketd@7a8683dc7f (2026-09-03).
Data as JSON: /api/errors/add29a8bfc9488f2.
Report an issue: GitHub.