bazelbuild / bazelbuild/bazel-toolchains

Build fails on Mac

Open
#523 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
202
Forks
100
PR merge metrics
No merged PRs in 30d

Description

When building the [`layer-definitions`](https://github.com/GoogleCloudPlatform/layer-definitions) repo on Mac, I get build failures:

```Bash
layer-definitions (master)$ bazel-0.25.2 build ...
INFO: Analyzed 110 targets (0 packages loaded, 0 targets configured).
INFO: Found 110 targets...
ERROR: ~/source/layer-definitions/layers/ubuntu1404/java/BUILD:85:1: error executing shell command: '/bin/bash -c tar cvf bazel-out/darwin-fastbuild/bin/layers/ubuntu1
404/java/java-ltl-packages.tar --files-from /dev/null && for i in external/ubuntu1404_java_debs/file/20190228_java_debs.tar...' failed (Exit 1) bash failed: error executing command /
bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Usage:
List: tar -tf
Extract: tar -xf
Create: tar -cf [filenames...]
Help: tar --help
INFO: Elapsed time: 0.441s, Critical Path: 0.16s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
```

This seems to be an issue with calling `tar`, which has different parameters for the GNU and BSD versions. This seems to be [the offending call](https://github.com/bazelbuild/bazel-toolchains/blob/e703fbf6eac46761d58765b30030ed5501b49211/rules/container/docker_toolchains.bzl#L143):

```Python
ctx.actions.run_shell(
inputs = installables_tars,
outputs = [final_installables_tar],
command = "tar cvf {output_tar} --files-from /dev/null && \
for i in {input_tars}; do tar A --file={output_tar} $i; done".format(
output_tar = final_installables_tar.path,
input_tars = " ".join(installables_tars_paths),
),
)
```

It looks like this needs to be factored out into a binary that can be platformed as a toolchain.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the reported bazel-0.25.2 build command and inspect layers/ubuntu1404/java/BUILD. Then read rules/container/docker_toolchains.bzl around line 143, focusing on the GNU/BSD tar invocation and the proposed platform-specific toolchain. Done means the affected build works on Mac without breaking the existing tar-based flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, shell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.