Skip to content

Bazel fails to create symlinks on slightly older versions of Windows #13169

@konste

Description

@konste

Description of the problem / feature request:

When symlinks support is enabled for Windows platform with the startup option --windows_enable_symlinks it only works on Windows version 1703 (Creators Update, build 15063) and above. Symlink creation fails on earlier versions of Windows even though symlinks are supported since Windows Vista and the process is elevated.

Feature requests: what underlying problem are you trying to solve with this feature?

While dev machines tend to be rather up to date, the build servers are often stale. In our company we use Windows Server 2016 version 1607 and Bazel build fails to create symlinks there despite the feature is fully supported in that version of Windows.

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

This is the place in the Bazel code which causes the problem. The code at fault looks like this:

  if (!CreateSymbolicLinkW(name.c_str(), target.c_str(),
                           SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)) {

While symlinks are supported in Windows for 15 years (since Vista) that particular flag SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is relatively new and recognized by Windows only starting from version 1703 (Creators Update, build 15063). On previous versions it causes CreateSymbolicLinkW to fail with GetLastError() returning 0x57 ERROR_INVALID_PARAMETER.

It would be great if Bazel checks the version of the OS and only apply SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE when it is supported by the underlying platform.

What operating system are you running Bazel on?

Windows, Linux, Mac.

What's the output of bazel info release?

4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)area-WindowsWindows-specific issues and feature requeststeam-Remote-ExecIssues and PRs for the Execution (Remote) teamtype: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions