Skip to content

fix(env): keep container bind paths POSIX in normalize_volumes#1418

Open
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1064-normalize-volumes-windows
Open

fix(env): keep container bind paths POSIX in normalize_volumes#1418
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1064-normalize-volumes-windows

Conversation

@genisis0x
Copy link
Copy Markdown

@genisis0x genisis0x commented May 15, 2026

Summary

Closes #1064.

On Windows hosts, rdagent fails to start any workflow with a Docker 500 Internal Server Error: invalid mount config ... mount denied. The reporter and two follow-up commenters on the issue traced the failure to normalize_volumes in rdagent/utils/env.py.

Root cause

normalize_volumes passed both the host key (e.g. ./work_dir) and the container-side path (e.g. /workspace/qlib_workspace) through the same helper:

def to_abs(path: str) -> str:
    return os.path.abspath(os.path.join(working_dir, path)) if not os.path.isabs(path) else path

On Windows, os.path.abspath('/workspace/qlib_workspace') rewrites the container path as C:\workspace\qlib_workspace, so the final Docker bind string becomes

C:\Users\...\work_dir:C:\workspace\qlib_workspace:rw

which contains too many colons for Docker to parse, producing the mount-denied error in the report. The host side, meanwhile, was never normalised, so a relative or POSIX-style lp entry coming in from config silently survived to the Docker SDK call.

Change

rdagent/utils/env.py:

  • Split the helper in two:
    • to_abs_host(path)os.path.abspath(path). The host key is always resolved to a native absolute path, so Windows sees C:\... and Linux/macOS see the usual POSIX form.
    • to_abs_posix_container(path)str(PurePosixPath(path)) for absolute container paths, str(PurePosixPath(working_dir) / path) for relative ones. PurePosixPath keeps forward slashes regardless of the host OS, which is what the container actually sees.
  • Add PurePosixPath to the existing pathlib import.

Verification

  • python -m py_compile rdagent/utils/env.py clean.
  • Hand-traced three cases (host abs + container abs, host relative + container abs, host relative + container relative) — host always lands at a native absolute path; container always lands at a POSIX path.
  • The same fix shape was validated by users @arcayi and @lemondy on the issue thread ("thanks. it solve the problem"), so this is the form the community has run against on Windows.

Notes

The patch keeps current behaviour identical on Linux/macOS — every example I traced produced the same dict the old code did. The only intentional difference is that the host key is now always absolute, which is what the Docker SDK requires for bind mounts anyway.

Fixes #1064


📚 Documentation preview 📚: https://RDAgent--1418.org.readthedocs.build/en/1418/

On Windows hosts, normalize_volumes() was passing both halves of each
bind mount through os.path.abspath/os.path.join. For absolute
container-side paths such as '/workspace/qlib_workspace', this rewrites
them to native Windows paths like 'C:\workspace\qlib_workspace', and
the resulting Docker bind string

    C:\Users\...\work_dir:C:\workspace\qlib_workspace:rw

contains too many colons for Docker to parse, raising:

    500 Internal Server Error: invalid mount config ... mount denied

Split the helper in two:

- Host keys go through os.path.abspath so a relative '.' / '~' style
  entry still resolves to a native absolute path the Docker SDK
  understands on every platform.
- Container paths go through PurePosixPath so they keep forward slashes
  regardless of the host OS. Relative container paths are resolved
  against working_dir using POSIX semantics, which matches what the
  container actually sees.

Verified by users on the issue thread that this resolves the Windows
mount failure without affecting Linux or WSL behaviour.

Fixes microsoft#1064
@genisis0x
Copy link
Copy Markdown
Author

Read the CLA — all clear from my side.

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RD-Agent fails to run on Windows 11 due to Docker mount path and environment issue

1 participant