{"record":{"id":"42ece7b89db66520","repo":"helix-editor/helix","slug":"working-dir-must-specify-an-initial-working-dire","errorCode":null,"errorMessage":"--working-dir must specify an initial working directory","messagePattern":"--working-dir must specify an initial working directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helix-term/src/args.rs","lineNumber":91,"sourceCode":"                    Some(path) => args.config_file = Some(path.into()),\n                    None => anyhow::bail!(\"--config must specify a path to read\"),\n                },\n                \"--log\" => match argv.next().as_deref() {\n                    Some(path) => args.log_file = Some(path.into()),\n                    None => anyhow::bail!(\"--log must specify a path to write\"),\n                },\n                \"-w\" | \"--working-dir\" => match argv.next().as_deref() {\n                    Some(path) => {\n                        args.working_directory = if Path::new(path).is_dir() {\n                            Some(PathBuf::from(path))\n                        } else {\n                            anyhow::bail!(\n                                \"--working-dir specified does not exist or is not a directory\"\n                            )\n                        }\n                    }\n                    None => {\n                        anyhow::bail!(\"--working-dir must specify an initial working directory\")\n                    }\n                },\n                arg if arg.starts_with(\"--\") => {\n                    anyhow::bail!(\"unexpected double dash argument: {}\", arg)\n                }\n                arg if arg.starts_with('-') => {\n                    let arg = arg.get(1..).unwrap().chars();\n                    for chr in arg {\n                        match chr {\n                            'v' => args.verbosity += 1,\n                            'V' => args.display_version = true,\n                            'h' => args.display_help = true,\n                            _ => anyhow::bail!(\"unexpected short arg {}\", chr),\n                        }\n                    }\n                }\n                \"+\" => line_number = usize::MAX,\n                arg if arg.starts_with('+') => {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-term/src/args.rs#L73-L109","documentation":"The -w/--working-dir option requires a value; when argv.next() returns None (option is the last token on the command line) the parser bails before any filesystem check.","triggerScenarios":"'hx -w' with nothing after it; 'hx -w' as the last token of a truncated script line; a following token that the shell consumed as a redirect (e.g. 'hx -w >log' leaves no value).","commonSituations":"Script variable expansion to empty ('hx -w \"$DIR\"' with unset DIR and 'set -u' absent - the next() is None); line-wrapped commands losing the argument.","solutions":["Provide the directory: hx -w /path/to/dir","In scripts, guard: [ -n \"$DIR\" ] && set -- -w \"$DIR\" \"$@\"; or default DIR=${DIR:-$PWD}","Distinguish from error [17]: this one means NO value was given at all"],"exampleFix":"# before\nhx -w              # no value\nhx -w \"$DIR\"        # $DIR unset/empty\n\n# after\nDIR=\"${DIR:-$PWD}\"\nhx -w \"$DIR\" file.rs","handlingStrategy":"validation","validationCode":"# Script guard: refuse empty working-dir values\n: \"${WD:?WD must be set to an existing directory}\"\nexec hx -w \"$WD\" \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply a value immediately after -w/--working-dir","Use 'set -u' in scripts to catch empty variable expansions early","A missing value (this error) differs from a non-directory value (error 17) - check which one you hit"],"tags":["rust","helix","cli","args","working-dir"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}