Repository navigation
fix(windows): support long runfiles paths without LongPathsEnabled - #4572
Open
AustinSchuh wants to merge 2 commits into
Open
AustinSchuh wants to merge 2 commits into
AustinSchuh wants to merge 2 commits into
Conversation
…symlinks `test_replaces_dangling_package_link_before_creating_child_link` needs to create symlinks, so it fails on Windows without the privilege to create them. Skip it there. The junction case still runs.
Without `LongPathsEnabled`, which is off by default, Windows paths of 260 characters or more fail unless they have the `\\?\` prefix. The bootstrap skipped the prefix on any Windows 10 1607 or later, so long runfiles paths broke binaries that can't create symlinks: * The fallback for when symlinks can't be created opens the runfiles files to hard link or copy them, which fails with `WinError 3`. * `os.path.exists()` is False for a long `Lib` path, so the runtime venv silently had no `site-packages`. * The check of `RUNFILES_DIR` failed, so it was cleared, and the site init then used `C:\` as the runfiles root and put every directory in `C:\` on `sys.path`. Add the prefix to paths that are long enough to need it, on any Windows version, and use it in the fallback, the venv setup and the runfiles root checks. Short paths are unchanged. This also fixes a `NameError` in the stage 2 copy of the helper, which never defined `unicode_prefix`. Share the bootstrap loader of `cached_venv_dangling_symlink_test` with a new test for long paths.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE: awaiting #4571
Without
LongPathsEnabled, which is off by default, Windows paths of260 characters or more fail unless they have the
\\?\prefix. Thebootstrap skipped the prefix on Windows 10 1607 and later, so long
runfiles paths broke binaries that can't create symlinks (#4509):
(
WinError 3).os.path.exists()is False for a longLibpath, so the runtimevenv silently has no
site-packages.RUNFILES_DIRcheck fails, so it's cleared, and the site initthen uses
C:\as the runfiles root and puts every directory inC:\onsys.path.This adds the prefix to paths that are long enough to need it, on any
Windows version, and uses it in the fallback, the venv setup and the
runfiles root checks. Short paths are unchanged. It also fixes a
NameErrorin the stage 2 copy of the helper, which never definedunicode_prefix.Note for review: this applies to all Windows users, not only those
without symlinks. Also,
_symlink_treenow walks the runfiles venvwith the prefix, so on machines that can create symlinks, the venv's
symlinks store
\\?\targets.Tested on Windows 11 26H2 with Developer Mode off and
LongPathsEnabled=0, Bazel 9.1.1,--nowindows_enable_symlinks:run_binary_without_symlinks_test,cached_venv_replaces_dangling_package_symlink_testandabi3_headers_linkage_test_pyfail without this and pass with it.windows_long_paths_testfails without this and passeswith it.
//tests/bootstrap_impls/...,//tests/cc/...and//tests/runfiles/...pass on Linux.Two other failures without symlinks are Bazel issues and aren't fixed
here:
.exe,.dlland.pydoutputs are junctions to files, which can't be opened.
--nobuild_runfile_linksavoids it.