{"record":{"id":"e664e0c34662f501","repo":"joewalnes/websocketd","slug":"could-not-resolve-absolute-path-to-dir-s","errorCode":null,"errorMessage":"could not resolve absolute path to dir '%s'","messagePattern":"could not resolve absolute path to dir '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config.go","lineNumber":219,"sourceCode":"\t\t\treturn \"\", nil, fmt.Errorf(\"ambiguous: provided COMMAND and --dir argument, please only specify one\")\n\t\t}\n\t\tpath, lookErr := exec.LookPath(args[0])\n\t\tif lookErr != nil {\n\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() {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/joewalnes/websocketd/blob/7a8683dc7f9778dc615945aaed2a8dc77290227b/config.go#L201-L237","documentation":"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'.","triggerScenarios":"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).","commonSituations":"Systemd/supervisor setups where the WorkingDirectory was removed; running from a deleted mount point; chroot or sandbox environments with an unset/invalid cwd.","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"],"exampleFix":"// before (launched from a deleted directory)\nwebsocketd --dir=scripts\n// after\ncd /srv/myapp && websocketd --dir=/srv/myapp/scripts","handlingStrategy":"validation","validationCode":"wd, err := os.Getwd()\nif err != nil {\n\tlog.Fatalf(\"working directory unusable: %v\", err)\n}\nif _, err := os.Stat(wd); err != nil {\n\tlog.Fatal(\"cwd deleted; restart from a valid directory\")\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"websocketd\", \"--dir=scripts\").CombinedOutput()\nif err != nil && strings.Contains(string(out), \"could not resolve absolute path\") {\n\t// restart process from a valid cwd before retrying\n}","preventionTips":["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"],"tags":["cli","filesystem","path"],"backgroundTag":"path-resolution-failed","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"}