{"record":{"id":"98399617da1970e7","repo":"joewalnes/websocketd","slug":"did-you-mean-to-specify-command-instead-of-dir","errorCode":null,"errorMessage":"did you mean to specify COMMAND instead of --dir '%s'?","messagePattern":"did you mean to specify COMMAND instead of --dir '(.+?)'\\?","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config.go","lineNumber":226,"sourceCode":"\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}\n\nfunc parseCommandLine() *Config {\n\tvar mainConfig Config","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/joewalnes/websocketd/blob/7a8683dc7f9778dc615945aaed2a8dc77290227b/config.go#L208-L244","documentation":"resolveScriptDir finds that the --dir path exists (os.Stat succeeded) but is a regular file, not a directory, and suggests the user probably meant to run it as COMMAND. It disambiguates the common mistake of passing a script file to --dir instead of a directory containing scripts.","triggerScenarios":"`websocketd --dir=./scripts/count.sh` — the path exists but IsDir() is false, so resolveScriptDir returns this hint instead of an ambiguous or not-found error.","commonSituations":"Passing a single script to --dir out of habit from other tools; tab-completion mistakes; swapping flags when converting a single-script command line to directory mode.","solutions":["If you meant to run one script: drop --dir and pass it as COMMAND (`websocketd ./scripts/count.sh`)","If you meant directory mode: point --dir at the containing directory (`websocketd --dir=./scripts`)"],"exampleFix":"// before\nwebsocketd --dir=./scripts/count.sh\n// after\nwebsocketd --dir=./scripts        # directory mode\n# or\nwebsocketd ./scripts/count.sh     # single command mode","handlingStrategy":"validation","validationCode":"inf, err := os.Stat(target)\nif err != nil {\n\tlog.Fatal(err)\n}\nif inf.IsDir() {\n\texec.Command(\"websocketd\", \"--dir=\"+target).Run()\n} else {\n\texec.Command(\"websocketd\", target).Run()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember --dir takes a directory, COMMAND takes the executable — pick per target type","Stat the path and choose the flag/argument form accordingly","Watch for tab-completion picking a file instead of the sibling directory"],"tags":["cli","configuration","directory"],"backgroundTag":"path-is-not-a-directory","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"}