{"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":1250,"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 super::*;\n\n    #[test]\n    /// Keep early recognition consistent with the full parser across inherited flag placements.\n    fn packages_where_classifier_accepts_global_and_parent_flags() {\n        let cases: &[&[&str]] = &[\n            &[\"mise\", \"bootstrap\", \"packages\", \"where\", \"brew:widget\"],","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/mod.rs#L1232-L1268","documentation":"mise validates the path passed to the global --cd flag before switching directories. After checking existence, it verifies the path is actually a directory; a file, symlink target, or special node fails this check. The error prevents mise from operating in a non-directory path.","triggerScenarios":"Running any mise command with `mise --cd <path> ...` (or env-var equivalent) where <path> exists on disk but is not a directory — e.g. pointing --cd at a file, socket, or fifo.","commonSituations":"Typo where the user passes a config file instead of its directory (`--cd ./mise.toml`), scripts that interpolate a variable that resolves to a file path, or a symlink that resolves to a file.","solutions":["Pass a directory path instead of a file path to --cd (e.g. the project root, not mise.toml)","Run `ls -la` on the path to confirm what it points to and correct typos","If you intended mise to use a specific config file, use MISE_CONFIG_FILE instead of --cd"],"exampleFix":"// before\nmise --cd ./mise.toml run build\n// after\nmise --cd . run build","handlingStrategy":"validation","validationCode":"if [ -d \"$dir\" ]; then mise --cd \"$dir\" run build; else echo \"--cd requires a directory: $dir\" >&2; exit 1; fi","typeGuard":"const isDir = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();","tryCatchPattern":null,"preventionTips":["Always pass the project root directory to --cd, never a file","Resolve variables used in --cd with realpath before invoking mise","If targeting a config file, use MISE_CONFIG_FILE instead of --cd"],"tags":["cli","path","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}