Skip to content

ctx.actions.symlink + building without the bytes misbehaves on Windows #21747

@hauserx

Description

@hauserx

Description of the bug:

The issue seems to be that if built normally, the builder_reset\builder.exe created in rules_go below through ctx.actions.symlink (link) is a regular file when run without cache, but is JUNCTION when taken from remote cache.

Looks like junctions for files do not work well under Windows.

Below reproduction on hello world example using rules_go: https://github.com/hauserx/rules-go-startup

After regular build:

> dir C:\b\execroot\_main\bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\go_sdk\builder_reset
2024-03-20  15:57         5,992,448 builder.exe

After taking from remote cache:

> dir C:\b\execroot\_main\bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\go_sdk\builder_reset
2024-03-20  15:48    <JUNCTION>     builder.exe [C:\b\execroot\_main\bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\go_sdk\builder.exe]

>bazel clean
Starting local Bazel server and connecting to it...
INFO: Starting clean.

>bazel build :hello --remote_cache=<remote cache>
Target //:hello up-to-date:
  bazel-bin/hello_/hello.exe
INFO: Build completed successfully, 11 total actions

>bazel clean
INFO: Starting clean.

>bazel build :hello --remote_cache=<remote cache>
INFO: 11 processes: 4 remote cache hit, 7 internal.
INFO: Build completed successfully, 11 total actions

>bazel build :hello
INFO: Analyzed target //:hello (0 packages loaded, 0 targets configured).
ERROR: C:/b/external/io_bazel_rules_go/BUILD.bazel:42:7: GoStdlib external/io_bazel_rules_go/stdlib_/pkg failed: (Exit -1): builder.exe failed: error executing GoStdlib command (from target @@io_bazel_rules_go//:stdlib) bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\go_sdk\builder_reset\builder.exe stdlib -sdk external/go_sdk -installsuffix windows_amd64 -out ... (remaining 5 arguments skipped)
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\b\execroot\_main\bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\go_sdk\builder_reset\builder.exe" stdlib -sdk external/go_sdk -installsuffix windows_amd64 -out bazel-out/x64_windows-fastbuild/bin/external/io_bazel_rules_go/stdlib_ -package std -gcflags ""): Access is denied.
 (error: 5)
Target //:hello failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 26.594s, Critical Path: 25.80s
INFO: 3 processes: 2 internal, 1 local.
ERROR: Build did NOT complete successfully

Which category does this issue belong to?

Core

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

No response

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 7.1.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 ?

No response

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?

Below bug describes some non-deterministic behavior with same symptoms.
#19018
In contrary this bug is fully reproducible and seems to be caused by build without bytes behavior.

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

No response

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: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions