jdx/mise · error
Directory specified with --cd does not exist: {} Please chec
Error message
Directory specified with --cd does not exist: {}
Please check the path and try again. What it means
mise validates the global `--cd` flag (validate_cd_path) before running any subcommand. This error means the directory you passed with `--cd` does not exist on disk, so mise refuses up front rather than running the command against a wrong or default working directory.
Source
Thrown at src/cli/mod.rs:982
/// Check if the current working directory exists and warn if not
fn check_working_directory() {
if std::env::current_dir().is_err() {
// Try to get the directory path from PWD env var, which might still contain the old path
let dir_path = std::env::var("PWD")
.or_else(|_| std::env::var("OLDPWD"))
.unwrap_or_else(|_| "(unknown)".to_string());
warn!(
"Current directory does not exist or is not accessible: {}",
dir_path
);
}
}
/// Validate the --cd path if provided and return an error if it doesn't exist
fn validate_cd_path(cd: &Option<PathBuf>) -> Result<()> {
if let Some(path) = cd {
if !path.exists() {
bail!(
"Directory specified with --cd does not exist: {}\n\
Please check the path and try again.",
ui::style::epath(path)
);
}
if !path.is_dir() {
bail!(
"Path specified with --cd is not a directory: {}\n\
Please provide a valid directory path.",
ui::style::epath(path)
);
}
}
Ok(())
}
#[cfg(test)]
mod tests {View on GitHub (pinned to 6f52dcdf99)
Solutions
- Fix the path or typo and re-run (`ls` the directory to confirm it exists)
- Use an absolute path so it does not depend on your current cwd
- If the path comes from a variable, verify it is set and expands correctly (echo "$DIR" before running)
Example fix
# before mise --cd ~/projct use node # after mise --cd ~/project use node
Defensive patterns
Strategy: validation
Validate before calling
# bash: guard before invoking mise
dir="${1:?usage: mise --cd <dir> ...}"
[ -d "$dir" ] || { echo "refusing: --cd dir does not exist: $dir" >&2; exit 1; }
mise --cd "$dir" use node Type guard
is_valid_cd_dir() { [ -d "$1" ]; } # existence implied by -d Prevention
- Expand and `ls` the directory once when writing the command instead of relying on stale history
- Prefer absolute paths (or $PWD-based) for --cd in scripts
- Derive --cd from a verified root (e.g. `git rev-parse --show-toplevel`) rather than hardcoding
When it happens
Trigger: Any subcommand with a nonexistent `--cd` path: `mise --cd /home/me/old-project use node`, a deleted/renamed directory, a typo, or a relative path resolved from the current cwd that does not exist there.
Common situations: Renamed or moved project while shell history still holds the old path; CI checkout directory changed; path built from an unset env var; tab-completion typo.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Path specified with --cd is not a directory: {} Please provi
- trimSuffix requires exactly 2 arguments
- workspace project {id:?} has absolute root {root:?}; roots m
- workspace project {id:?} has root {root:?} that escapes the
- trimPrefix requires exactly 2 arguments
AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22).
Data as JSON: /api/errors/f7781ab5fbcfa814.
Report an issue: GitHub.