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.
Description of the bug:
On Windows,
bazel testfails for any test run through the native Windows test wrapper (tw.exe, the default per--incompatible_windows_native_test_wrapper) whose runfiles directory path exceedsMAX_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):Windows error 206 is
ERROR_FILENAME_EXCED_RANGE, fromChdirToRunfiles's call toSetCurrentDirectoryWintools/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 testinvocation whose runfiles directory path exceeds 260 characters reproduces this.For example, a
cc_testtarget 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 releasereturnsdevelopment versionor(@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 ofSetCurrentDirectoryWwithout 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?
SetCurrentDirectoryfailing on paths overMAX_PATHwith error 206, even with the\\?\prefix, reproduced on Windows Server 2008/2012/2016/2019)CreateProcessW/lpApplicationNamefix that does not cover this code path)MAX_PATHbug inrules_cc'sRunfiles::Createthat can also affect Windows test executionbazel runbeforebazel testfails withCould not chdiron Windows #10621 and Cannot run sh_test tests on Windows [#6622 will fix it] #7387 share the "Could not chdir" error text from the sameChdirToRunfilescall site, but are a different bug (a missing runfiles directory frombazel run/bazel testordering, error code 2/ERROR_FILE_NOT_FOUND, notMAX_PATH/error 206)Any other information, logs, or outputs that you want to share?
Fix in progress.