jdx/mise · error
Directory specified with --cd does not exist
Error message
Directory specified with --cd does not exist: {}
Please check the path and try again. What it means
mise validates the `--cd` global flag before executing any command. If the supplied path does not exist, it cannot change the working directory for config discovery, so it fails fast with this message.
Solutions
- Check the path spelling and existence: `ls <path>` before running mise
- Create the directory first if it is generated (`mkdir -p "$DIR"`), then run mise
- Verify shell variables used in the path expand correctly (echo them before the mise call)
Example fix
// before mise --cd "$BUILD_DIR" install // after mkdir -p "$BUILD_DIR" mise --cd "$BUILD_DIR" install
Defensive patterns
Strategy: validation
Validate before calling
// bash: verify the directory before passing --cd
[[ -d "$DIR" ]] || { echo "$DIR missing"; exit 1; }
mise --cd "$DIR" install Prevention
- Always `mkdir -p`/verify directories referenced by --cd
- Quote and echo path variables in scripts to catch empty expansions
- Run mise commands from existing directories when possible
When it happens
Trigger: Running any mise command with `mise --cd <path> <cmd>` where `<path>` does not exist on disk (typo, deleted directory, not-yet-created build dir).
Common situations: CI scripts computing the path dynamically with a typo; referencing a directory created later in the script; shell variable expansion producing an empty or wrong path.
Related errors
- --localized-dir cannot be carried to Windows: is not…
- {msg}
- Path does not exist: mise resolves this to a trust root…
- Path specified with --cd is not a directory
- : target must be absolute or start with ~/
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/f7781ab5fbcfa814.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/mod.rs:1243
/// 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 533346cc37)