{"record":{"id":"d0b17ba482abfaba","repo":"junegunn/fzf","slug":"no-directory-specified","errorCode":null,"errorMessage":"no directory specified","messagePattern":"no directory specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":2612,"sourceCode":"\t}\n\n\tnextDirs := func() ([]string, error) {\n\t\tdefer func() { val = nil }()\n\t\tdirs := []string{}\n\t\tif val != nil {\n\t\t\tdirs = append(dirs, *val)\n\t\t}\n\t\tfor i < len(allArgs)-1 {\n\t\t\targ := allArgs[i+1]\n\t\t\tif isDir(arg) {\n\t\t\t\tdirs = append(dirs, arg)\n\t\t\t\ti++\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif len(dirs) == 0 {\n\t\t\treturn nil, errors.New(\"no directory specified\")\n\t\t}\n\t\treturn dirs, nil\n\t}\n\n\tnextInt := func(message string) (int, error) {\n\t\tdefer func() { val = nil }()\n\t\tvar str string\n\t\tif val != nil {\n\t\t\tstr = *val\n\t\t} else if len(allArgs) > i+1 {\n\t\t\ti++\n\t\t\tstr = allArgs[i]\n\t\t} else {\n\t\t\treturn 0, errors.New(message)\n\t\t}\n\t\tn, err := atoi(str)\n\t\tif err != nil {\n\t\t\treturn 0, errors.New(message)","sourceCodeStart":2594,"sourceCodeEnd":2630,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L2594-L2630","documentation":"Thrown by the dirs parser used by --cwd options (e.g. --cwd walking arguments). It collects a directory from the option value and then greedily consumes following arguments while isDir(arg) holds; if no directory at all was collected (empty value and next argument not a directory), the error fires.","triggerScenarios":"`--cwd` with an empty value (`--cwd=''`) where the next positional argument is a file, not a directory; `--cwd` followed by another option flag instead of a path; pointing --cwd at a nonexistent path.","commonSituations":"Optional-variable configs where the cwd path is empty or unset: `fzf --cwd \"$PROJECT_DIR\"` with PROJECT_DIR unset and the next token being another flag; typos in the directory path making isDir false.","solutions":["Supply an existing directory path to --cwd: `--cwd /path/to/dir`","Default the variable: `--cwd \"${PROJECT_DIR:-$HOME}\"`","Verify the path exists and is a directory before calling fzf: [ -d \"$d\" ] || exit 1"],"exampleFix":"# before\nfzf --cwd \"$PROJECT_DIR\"   # unset\n# after\nfzf --cwd \"${PROJECT_DIR:-$PWD}\"","handlingStrategy":"validation","validationCode":"# bash: --cwd must name an existing directory\nCWD=\"${CWD:-$PWD}\"\n[ -d \"$CWD\" ] || { echo \"--cwd: not a directory: $CWD\" >&2; exit 1; }\nfzf --cwd \"$CWD\"","typeGuard":"is_dir() { [ -d \"$1\" ]; }","tryCatchPattern":null,"preventionTips":["Always default --cwd variables (${VAR:-$PWD})","Pre-check existence when the path comes from user input or env"],"tags":["fzf","go","cli","filesystem","options"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}