Skip to content

LocalEnvironment: repeated 'cwd missing on disk' warning on Windows with git-bash MSYS paths #23846

@jerrydong1988

Description

@jerrydong1988

Description

On Windows when running Hermes under git-bash (MSYS2), os.getcwd() returns MSYS-style paths like /c/Users/user. The _resolve_safe_cwd() function in tools/environments/local.py calls os.path.isdir() which does NOT understand MSYS paths — it returns False because Windows doesn't have a literal /c/ directory.

This triggers the following WARNING on every terminal command:

WARNING tools.environments.local: LocalEnvironment cwd '/c/Users/user' is missing on disk;
  falling back to '/' so terminal commands keep working.

Environment

  • Windows 11
  • Hermes running under git-bash (MSYS2 terminal)
  • os.getcwd() returns MSYS-format paths

Expected Behavior

_resolve_safe_cwd() should handle MSYS-style paths on Windows by converting them to native Windows paths (e.g., /c/Users/userC:\Users\user) before checking os.path.isdir().

The downstream code at local.py:457-459 already has a comment noting this is a Git Bash path and does the conversion for subprocess.Popen's cwd. The _resolve_safe_cwd() function should apply the same conversion.

Actual Behavior

The WARNING message fires once per terminal tool call. It's cosmetic (the actual command still works because the fallback / works as a working directory), but it creates log noise in the Dashboard's log viewer.

Root Cause

In tools/environments/local.py:21-45:

def _resolve_safe_cwd(cwd: str) -> str:
    if cwd and os.path.isdir(cwd):
        return cwd
    parent = os.path.dirname(cwd) if cwd else ""
    while parent:
        if os.path.isdir(parent):
            return parent
        ...
    return tempfile.gettempdir()

When cwd = '/c/Users/user', os.path.isdir('/c/Users/user') is False on Windows. It then walks up to /c/ and eventually falls back to tempfile.gettempdir(). Adding MSYS-to-Windows path normalization before the isdir check would fix this.

Related

See also: the downstream code at local.py:457-459 already has this comment:

# On Windows, self.cwd may be a Git Bash-style path (/c/Users/...)
# from pwd output. subprocess.Popen needs a native Windows path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havebackend/localLocal shell executioncomp/toolsTool registry, model_tools, toolsetssweeper:implemented-on-mainSweeper: behavior already present on current maintool/terminalTerminal execution and process managementtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions