Skip to content

Shell tool fails with "The directory name is invalid" (os error 267) on Windows when workspace_dir doesn't match action_dir #3353

@Harryjsmith40

Description

@Harryjsmith40

Summary

On a Windows machine, every shell/command execution fails with Failed to execute command: The directory name is invalid. (os error 267) — even trivial commands like echo hello or pwd. The shell tool cannot initialise because the configured working directory is invalid at the OS level.

Problem

What happened: Every shell tool call (shell, node_exec, npm_exec) fails with the same error. Commands like echo hello, pwd, dir, ls all fail identically. The error is os error 267 which maps to Windows ERROR_DIRECTORY — the directory name is invalid.

What was expected: The shell tool should either (a) fall back to a valid directory, (b) surface a clear error about which path is invalid and why, or (c) auto-create the missing directory.

Impact: The agent is completely unable to execute any shell commands, read files, run scripts, or interact with the filesystem. This blocks all code-repo work, file operations, and general tool usage on Windows.

Version / Platform:

  • Platform: Windows 11 - 25H2 (OS Build 26200.8457)
  • OpenHuman version: v0.57.13

Solution (suspected)

The root cause is likely a mismatch between workspace_dir and action_dir:

  1. workspace_dir defaults to ~/.openhuman/users/<id>/workspace — this path is auto-created at startup and is valid.
  2. action_dir defaults to ~/OpenHuman/projects — this path is the shell tool's CWD. If it doesn't exist (e.g. the user never created it, or the tilde expansion produces a malformed Windows path like C:\Users\Harry/OpenHuman/projects with mixed separators), cmd.current_dir() will fail with ERROR_DIRECTORY.
  3. The shell tool does NOT check if action_dir exists before setting it as CWD — it just passes it to cmd.current_dir() and lets the OS error bubble up as a generic "Failed to execute command" message.
  4. The error message is opaque — it doesn't tell the user WHICH directory is invalid or why.

Related: Issue #2379 (closed) fixed a similar "program not found" problem on Windows by adding Windows env vars to the allowlist. This is a different failure mode (invalid directory path vs missing executable).

Acceptance criteria

  • Repro gone — Shell commands no longer fail with ERROR_DIRECTORY on Windows when action_dir doesn't exist
  • Clear error messaging — If action_dir is invalid, the error message tells the user which path is the problem and suggests a fix (e.g. "The configured action_dir 'X' does not exist. Set a valid path in Settings → Agent → Working Directory or create the directory.")
  • Auto-creation or fallback — Either auto-create action_dir at startup (like workspace_dir is), or fall back to a valid temp directory with a warning
  • Diff coverage ≥ 80%

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions