{"record":{"id":"6bbe9e02fe5e8455","repo":"jdx/mise","slug":"path-specified-with-cd-is-not-a-directory-pl","errorCode":null,"errorMessage":"Path specified with --cd is not a directory: {}\nPlease provide a valid directory path.","messagePattern":"Path specified with --cd is not a directory: (.+?)\nPlease provide a valid directory path\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/mod.rs","lineNumber":989,"sourceCode":"        warn!(\n            \"Current directory does not exist or is not accessible: {}\",\n            dir_path\n        );\n    }\n}\n\n/// Validate the --cd path if provided and return an error if it doesn't exist\nfn validate_cd_path(cd: &Option<PathBuf>) -> Result<()> {\n    if let Some(path) = cd {\n        if !path.exists() {\n            bail!(\n                \"Directory specified with --cd does not exist: {}\\n\\\n                 Please check the path and try again.\",\n                ui::style::epath(path)\n            );\n        }\n        if !path.is_dir() {\n            bail!(\n                \"Path specified with --cd is not a directory: {}\\n\\\n                 Please provide a valid directory path.\",\n                ui::style::epath(path)\n            );\n        }\n    }\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use clap::Parser;\n\n    use super::*;\n\n    #[test]\n    fn test_commands_that_implicitly_trust_active_config() {\n        let trusting = [","sourceCodeStart":971,"sourceCodeEnd":1007,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cli/mod.rs#L971-L1007","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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"],"exampleFix":"# before\nmise --cd mise.toml tasks\n# after\nmise --cd . tasks","handlingStrategy":"validation","validationCode":"# bash: existence + directory + writability of intent\ndir=\"$1\"\n[ -d \"$dir\" ] || { echo \"not a usable --cd directory: $dir\" >&2; exit 1; }\nmise --cd \"$dir\" tasks","typeGuard":"is_cd_dir() { [ -d \"$1\" ] && [ ! -L \"$1\" -o -d \"$(readlink -f \"$1\")\" ]; }","tryCatchPattern":null,"preventionTips":["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)"],"tags":["mise","cd","path","cli","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}