jdx/mise · error

Directory specified with --cd does not exist: {} Please chec

Error message

Directory specified with --cd does not exist: {}
Please check the path and try again.

What it means

mise validates the global `--cd` flag (validate_cd_path) before running any subcommand. This error means the directory you passed with `--cd` does not exist on disk, so mise refuses up front rather than running the command against a wrong or default working directory.

Source

Thrown at src/cli/mod.rs:982

/// 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 6f52dcdf99)

Solutions

  1. Fix the path or typo and re-run (`ls` the directory to confirm it exists)
  2. Use an absolute path so it does not depend on your current cwd
  3. If the path comes from a variable, verify it is set and expands correctly (echo "$DIR" before running)

Example fix

# before
mise --cd ~/projct use node
# after
mise --cd ~/project use node
Defensive patterns

Strategy: validation

Validate before calling

# bash: guard before invoking mise
dir="${1:?usage: mise --cd <dir> ...}"
[ -d "$dir" ] || { echo "refusing: --cd dir does not exist: $dir" >&2; exit 1; }
mise --cd "$dir" use node

Type guard

is_valid_cd_dir() { [ -d "$1" ]; }   # existence implied by -d

Prevention

When it happens

Trigger: Any subcommand with a nonexistent `--cd` path: `mise --cd /home/me/old-project use node`, a deleted/renamed directory, a typo, or a relative path resolved from the current cwd that does not exist there.

Common situations: Renamed or moved project while shell history still holds the old path; CI checkout directory changed; path built from an unset env var; tab-completion typo.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22). Data as JSON: /api/errors/f7781ab5fbcfa814. Report an issue: GitHub.