bazelbuild/bazel

Windows: cannot shorten the path enough

Closed

#19,710 opened on Oct 3, 2023

 (1 comment) (6 reactions) (0 assignees)Java (4,465 forks)batch import
P2area-Windowshelp wantedteam-OSStype: bug

Repository metrics

Stars
 (25,384 stars)
PR merge metrics
 (Avg merge 22d 20h) (77 merged PRs in 30d)

Description

Description of the bug:

When running tests on windows with --windows_enable_symlinks and --enable_runfiles, the test would fail with

==================== Test output for //enterprise/server/remote_execution/commandutil:commandutil_test:
ERROR(tools/test/windows/tw.cc:1297) 
ERROR: src/main/native/windows/process.cc(95): WaitableProcess::Create(D:\0\ihlv26j4\execroot\buildbuddy\bazel-out\x64_windows-fastbuild\bin\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe.runfiles\buildbuddy\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe): 
ERROR: src/main/native/windows/util.cc(292): AsExecutablePathForCreateProcess(D:\0\ihlv26j4\execroot\buildbuddy\bazel-out\x64_windows-fastbuild\bin\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe.runfiles\buildbuddy\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe): 
ERROR: src/main/native/windows/util.cc(262): GetShortPathNameW(\\?\D:\0\ihlv26j4\execroot\buildbuddy\bazel-out\x64_windows-fastbuild\bin\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe.runfiles\buildbuddy\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe): cannot shorten the path enough

ERROR(tools/test/windows/tw.cc:1456) Failed to start test process (arg: D:\0\ihlv26j4\execroot\buildbuddy\bazel-out\x64_windows-fastbuild\bin\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe.runfiles\buildbuddy\enterprise\server\remote_execution\commandutil\commandutil_test_\commandutil_test.exe)
================================================================================

(reformatted log to multiple lines for readability)

This is not expected as the Windows instance has been configured with Long Paths support

Which category does this issue belong to?

Core, Local Execution

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

Perform any test on Windows with a sufficient long package path.

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 6.4.0rc1

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

N/A

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

N/A

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

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

https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getshortpathnamew

Starting with Windows 10, Version 1607, you can opt-in to remove the MAX_PATH limitation without prepending "\?". See the "Maximum Path Length Limitation" section of Naming Files, Paths, and Namespaces for details.

So ideally, we should just migrate Windows syscalls to the new behavior.

Contributor guide