{"record":{"id":"4d8f7fba3f31e55b","repo":"helix-editor/helix","slug":"working-dir-specified-does-not-exist-or-is-not-a","errorCode":null,"errorMessage":"--working-dir specified does not exist or is not a directory","messagePattern":"--working-dir specified does not exist or is not a directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helix-term/src/args.rs","lineNumber":85,"sourceCode":"                    Some(\"build\") => args.build_grammars = true,\n                    _ => {\n                        anyhow::bail!(\"--grammar must be followed by either 'fetch' or 'build'\")\n                    }\n                },\n                \"-c\" | \"--config\" => match argv.next().as_deref() {\n                    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,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-term/src/args.rs#L67-L103","documentation":"The -w/--working-dir value must be an existing directory: the parser checks Path::new(path).is_dir() and bails when the path does not exist or exists but is not a directory (a file, symlink to file, etc.).","triggerScenarios":"'hx -w /nonexistent'; '-w somefile.txt' (a regular file); a symlink to a directory that is broken; relative path evaluated against the current shell cwd that no longer exists (deleted terminal cwd).","commonSituations":"Typos in the path; passing a project FILE instead of its directory; shell started in a deleted cwd so relative -w values fail; tilde '~' inside quotes not expanded (is_dir sees the literal '~').","solutions":["Verify the path exists and is a directory: ls -ld <path>","Use $HOME instead of quoted '~', or keep ~ unquoted so the shell expands it","Pass the project root directory, not a file inside it"],"exampleFix":"# before\nhx -w \"~/projects/foo\"   # literal '~' not expanded -> is_dir() false\n\n# after\nhx -w \"$HOME/projects/foo\"","handlingStrategy":"validation","validationCode":"# Shell: verify the working dir exists and is a directory\nWD=\"${WD:-$PWD}\"\n[ -d \"$WD\" ] || { echo \"working dir invalid: $WD\" >&2; exit 2; }\nexec hx -w \"$WD\" \"$@\"","typeGuard":"fn is_valid_working_dir(p: &str) -> bool { std::path::Path::new(p).is_dir() }","tryCatchPattern":null,"preventionTips":["Pass an existing directory (not a file) to -w/--working-dir","Use $HOME instead of quoted '~'","Watch out for broken symlinks and deleted terminal cwds when using relative paths"],"tags":["rust","helix","cli","args","filesystem","working-dir"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}