{"record":{"id":"add29a8bfc9488f2","repo":"joewalnes/websocketd","slug":"could-not-find-your-script-dir-s","errorCode":null,"errorMessage":"could not find your script dir '%s'","messagePattern":"could not find your script dir '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config.go","lineNumber":223,"sourceCode":"\t\t\treturn \"\", nil, fmt.Errorf(\"unable to locate specified COMMAND '%s' in OS path\", args[0])\n\t\t}\n\t\treturn path, args[1:], nil\n\t}\n\treturn \"\", nil, nil\n}\n\n// resolveScriptDir validates and resolves the script directory path.\nfunc resolveScriptDir(dir string) (string, error) {\n\tif dir == \"\" {\n\t\treturn \"\", nil\n\t}\n\tabsDir, err := filepath.Abs(dir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not resolve absolute path to dir '%s'\", dir)\n\t}\n\tinf, err := os.Stat(absDir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not find your script dir '%s'\", dir)\n\t}\n\tif !inf.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"did you mean to specify COMMAND instead of --dir '%s'?\", dir)\n\t}\n\treturn absDir, nil\n}\n\n// validateDir checks that a directory path exists and is a directory.\nfunc validateDir(dir, label string) error {\n\tif dir == \"\" {\n\t\treturn nil\n\t}\n\tinf, err := os.Stat(dir)\n\tif err != nil || !inf.IsDir() {\n\t\treturn fmt.Errorf(\"your %s '%s' is not pointing to an accessible directory\", label, dir)\n\t}\n\treturn nil\n}","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/joewalnes/websocketd/blob/7a8683dc7f9778dc615945aaed2a8dc77290227b/config.go#L205-L241","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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"],"exampleFix":"// before\nwebsocketd --dir=./scriptz --port=8080\n// after\nwebsocketd --dir=/srv/app/scripts --port=8080","handlingStrategy":"validation","validationCode":"dir := \"/srv/app/scripts\"\nif inf, err := os.Stat(dir); err != nil || !inf.IsDir() {\n\tlog.Fatalf(\"script dir missing: %s\", dir)\n}\nexec.Command(\"websocketd\", \"--dir=\"+dir, \"--port=8080\").Run()","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"websocketd\", \"--dir=\"+dir).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"could not find your script dir\") {\n\tlog.Fatalf(\"fix --dir value %q: does not exist\", dir)\n}","preventionTips":["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"],"tags":["cli","filesystem","directory-not-found"],"backgroundTag":"directory-not-found","analyzedSha":"7a8683dc7f9778dc615945aaed2a8dc77290227b","analyzedAt":"2026-09-03T13:52:22.309Z","contentChangedAt":"2026-09-03T13:52:22.309Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}