tinyhumansai/openhuman · error

Working directory '{}' is not a directory. Set a valid path

Error message

Working directory '{}' is not a directory. Set a valid path in Settings → Agent access → Working directory.

What it means

`ensure_usable_cwd` validates the agent working/action directory: it creates the dir when missing (`create_dir_all`), then requires the path to actually be a directory. This bail fires when the path exists but is not a directory — a regular file or file-symlink occupies the location. The message directs the user to Settings → Agent access → Working directory, matching where the path is configured.

Source

Thrown at src/openhuman/config/ops/agent.rs:372

/// Ensure `dir` is usable as a process working directory: it must exist (we
/// attempt to create it if missing — covers a dir deleted after launch) and
/// resolve to a directory. Returns a descriptive error naming the path and the
/// Settings location to fix it, instead of letting the OS surface an opaque
/// `ERROR_DIRECTORY` (os error 267) from `CreateProcessW`. See issue #3353
/// (Fix 2). Cheap stat-only calls on the happy path.
pub fn ensure_usable_cwd(dir: &Path) -> anyhow::Result<()> {
    if !dir.exists() {
        std::fs::create_dir_all(dir).map_err(|e| {
            anyhow::anyhow!(
                "Working directory '{}' does not exist and could not be created: {e}. \
                 Set a valid path in Settings → Agent access → Working directory.",
                dir.display()
            )
        })?;
    }
    if !dir.is_dir() {
        anyhow::bail!(
            "Working directory '{}' is not a directory. \
             Set a valid path in Settings → Agent access → Working directory.",
            dir.display()
        );
    }
    Ok(())
}

fn action_dir_source(config: &Config) -> &'static str {
    if crate::openhuman::config::action_dir_env_override().is_some() {
        "env"
    } else if config.action_dir_override.is_some() {
        "override"
    } else {
        "default"
    }
}

View on GitHub (pinned to 7491200858)

Solutions

  1. Identify and remove/rename the file occupying the path (`ls -l <path>`) so the directory can be created on next start.
  2. Set the Working directory to a valid directory path in Settings → Agent access → Working directory.
  3. Fix OPENHUMAN_ACTION_DIR / action_dir_override to point at a directory; check symlinks resolve to directories.

Example fix

# before — a file occupies the directory path
$ ls -l ~/OpenHuman/projects
-rw-r--r-- 1 user users 0 Apr 1 00:00 projects

# after
$ rm ~/OpenHuman/projects && mkdir -p ~/OpenHuman/projects
Defensive patterns

Strategy: validation

Validate before calling

if dir.exists() && !dir.is_dir() {
    anyhow::bail!(
        "path occupied by a non-directory: {} — remove it or change the working directory",
        dir.display()
    );
}
ensure_usable_cwd(dir)?;

Type guard

fn is_usable_cwd(dir: &std::path::Path) -> bool {
    !dir.exists() || dir.is_dir()
}

Prevention

When it happens

Trigger: `action_dir` (default `~/OpenHuman/projects`, or the override / OPENHUMAN_ACTION_DIR env var) resolves to an existing non-directory: someone created the path as a file, a symlink points at a file, or the override value is a file path.

Common situations: Bootstrap scripts or notes tools that `touch`-created the path; a file path pasted into Settings → Agent access → Working directory; OPENHUMAN_ACTION_DIR pointed at a file; leftover artifacts named like the projects dir.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/f2e31cd0a0fd4b6e. Report an issue: GitHub.