Skip to content

bazel test fails on Windows with error 206 when the runfiles path exceeds MAX_PATH #30609

Description

@rdesgroppes

Description of the bug:

On Windows, bazel test fails for any test run through the native Windows test wrapper (tw.exe, the default per --incompatible_windows_native_test_wrapper) whose runfiles directory path exceeds MAX_PATH (260 characters).
This is easy to hit with long, tag-qualified or config-transition-suffixed target names combined with a deeply nested bazel-out/<platform>-<config-hash>/bin/... output tree.
The wrapper is generic Bazel test-execution machinery, so this applies regardless of the test rule (e.g., go_test):

ERROR(tools/test/windows/tw.cc:488) value: 206 (0x000000ce), arg: C:\...\<target>.exe.runfiles\_main: Could not chdir

Windows error 206 is ERROR_FILENAME_EXCED_RANGE, from ChdirToRunfiles's call to SetCurrentDirectoryW in tools/test/windows/tw.cc.

Envisioned fix direction: Windows 10 1607+'s longPathAware-manifest opt-in.

Which category does this issue belong to?

Local Execution

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Any Windows bazel test invocation whose runfiles directory path exceeds 260 characters reproduces this.

For example, a cc_test target with a long enough name that <output_base>/execroot/<repo>/bazel-out/<platform>/bin/<pkg>/<name>.exe.runfiles/<workspace> exceeds 260 characters.

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 9.2.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

Not believed to be a regression: ChdirToRunfiles's use of SetCurrentDirectoryW without long-path handling appears to predate any version we've checked and is unrelated to any specific recent change.

Have you found anything relevant by searching the web?

Any other information, logs, or outputs that you want to share?

Fix in progress.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, websitetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions