helix-editor/helix · error
--working-dir specified does not exist or is not a directory
Error message
--working-dir specified does not exist or is not a directory
What it means
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.).
Source
Thrown at helix-term/src/args.rs:85
Some("build") => args.build_grammars = true,
_ => {
anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'")
}
},
"-c" | "--config" => match argv.next().as_deref() {
Some(path) => args.config_file = Some(path.into()),
None => anyhow::bail!("--config must specify a path to read"),
},
"--log" => match argv.next().as_deref() {
Some(path) => args.log_file = Some(path.into()),
None => anyhow::bail!("--log must specify a path to write"),
},
"-w" | "--working-dir" => match argv.next().as_deref() {
Some(path) => {
args.working_directory = if Path::new(path).is_dir() {
Some(PathBuf::from(path))
} else {
anyhow::bail!(
"--working-dir specified does not exist or is not a directory"
)
}
}
None => {
anyhow::bail!("--working-dir must specify an initial working directory")
}
},
arg if arg.starts_with("--") => {
anyhow::bail!("unexpected double dash argument: {}", arg)
}
arg if arg.starts_with('-') => {
let arg = arg.get(1..).unwrap().chars();
for chr in arg {
match chr {
'v' => args.verbosity += 1,
'V' => args.display_version = true,
'h' => args.display_help = true,View on GitHub (pinned to 079a789e8c)
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
Example fix
# before hx -w "~/projects/foo" # literal '~' not expanded -> is_dir() false # after hx -w "$HOME/projects/foo"
Defensive patterns
Strategy: validation
Validate before calling
# Shell: verify the working dir exists and is a directory
WD="${WD:-$PWD}"
[ -d "$WD" ] || { echo "working dir invalid: $WD" >&2; exit 2; }
exec hx -w "$WD" "$@" Type guard
fn is_valid_working_dir(p: &str) -> bool { std::path::Path::new(p).is_dir() } Prevention
- 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
When it happens
Trigger: '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).
Common situations: 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 '~').
Related errors
- expected a path to file, but found a directory: {file:?}. (t
- --working-dir must specify an initial working directory
- can only set a split once of a specific type
- --grammar must be followed by either 'fetch' or 'build'
- --config must specify a path to read
AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16).
Data as JSON: /api/errors/4d8f7fba3f31e55b.
Report an issue: GitHub.