jdx/mise · error
Path specified with --cd is not a directory: {} Please provi
Error message
Path specified with --cd is not a directory: {}
Please provide a valid directory path. What it means
mise validates the global `--cd` flag (validate_cd_path) before running any subcommand. The path you passed exists but is a regular file, not a directory, so mise cannot chdir into it and fails up front with the offending path.
Source
Thrown at src/cli/mod.rs:989
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 {
use clap::Parser;
use super::*;
#[test]
fn test_commands_that_implicitly_trust_active_config() {
let trusting = [View on GitHub (pinned to 6f52dcdf99)
Solutions
- Pass the containing directory instead of the file (`mise --cd ~/project`, not `mise --cd ~/project/mise.toml`)
- Fix the variable or glob so it yields a directory
- Confirm with `test -d "$dir" && echo ok` before running
Example fix
# before mise --cd mise.toml tasks # after mise --cd . tasks
Defensive patterns
Strategy: validation
Validate before calling
# bash: existence + directory + writability of intent
dir="$1"
[ -d "$dir" ] || { echo "not a usable --cd directory: $dir" >&2; exit 1; }
mise --cd "$dir" tasks Type guard
is_cd_dir() { [ -d "$1" ] && [ ! -L "$1" -o -d "$(readlink -f "$1")" ]; } Prevention
- Remember --cd takes a directory, never a file — pass the project folder, not mise.toml or a script
- Test glob results with `test -d` before feeding them to --cd
- In wrappers, reject --cd values that end in known file extensions (.toml, .sh, .lock)
When it happens
Trigger: `mise --cd <path>` where <path> is a file: e.g. `mise --cd mise.toml tasks`, `mise --cd ./script.sh exec node --version`, or pointing at a symlink that resolves to a file.
Common situations: Passing a config or script file when a project directory was intended; copy-pasting a filename instead of its directory; glob expansion landing on a file.
Related errors
- Directory specified with --cd does not exist: {} Please chec
- 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/6bbe9e02fe5e8455.
Report an issue: GitHub.