rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

Avoid creating symlinks that point out of output TreeArtifact #313

Closed anguslees closed 3 months ago

anguslees commented 3 months ago

cp -r copies the symlinks, not the destination of symlinks. This results in a TreeArtifact with symlinks to content outside the TreeArtifact, which is not well defined in bazel[^1]. At least bazel 7.1.1's linux-sandbox (bazel --spawn_strategy=sandboxed on Linux) does not follow the symlinks and destroys the temporary directory containing the actual files after the action, leaving a TreeArtifact of dangling symlinks.

cp -rL chases the symlinks and creates a TreeArtifact of regular files. This has the desired behaviour in all bazel versions/sandboxes.

[^1]: See discussion in https://github.com/bazelbuild/bazel/issues/15454. It is unclear whether we want to resolve these symlinks or leave them dangling, and behaviour varies across bazel versions and execution environment.

aaliddell commented 3 months ago

Excellent thanks