jdx/mise · error

Path specified with --cd is not a directory

Error message

Path specified with --cd is not a directory: {}
Please provide a valid directory path.

What it means

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.

Solutions

  1. Pass a directory path instead of a file path to --cd (e.g. the project root, not mise.toml)
  2. Run `ls -la` on the path to confirm what it points to and correct typos
  3. If you intended mise to use a specific config file, use MISE_CONFIG_FILE instead of --cd

Example fix

// before
mise --cd ./mise.toml run build
// after
mise --cd . run build
Defensive patterns

Strategy: validation

Validate before calling

if [ -d "$dir" ]; then mise --cd "$dir" run build; else echo "--cd requires a directory: $dir" >&2; exit 1; fi

Type guard

const isDir = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/6bbe9e02fe5e8455. Report an issue: GitHub.

Appendix: source

Thrown at src/cli/mod.rs:1250

        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 super::*;

    #[test]
    /// Keep early recognition consistent with the full parser across inherited flag placements.
    fn packages_where_classifier_accepts_global_and_parent_flags() {
        let cases: &[&[&str]] = &[
            &["mise", "bootstrap", "packages", "where", "brew:widget"],

View on GitHub (pinned to 533346cc37)