Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go_download_sdk: work around Bazel .tar.gz extraction bug #2836

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions go/private/sdk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,30 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
if len(urls) == 0:
fail("no urls specified")
ctx.report_progress("Downloading and extracting Go toolchain")
ctx.download_and_extract(
url = urls,
stripPrefix = strip_prefix,
sha256 = sha256,
)
if urls[0].endswith(".tar.gz"):
# BUG(#2771): Use a system tool to extract the archive instead of
# Bazel's implementation. With some configurations (macOS + Docker +
# some particular file system binding), Bazel's implementation rejects
# files with invalid unicode names. Go has at least one test case with a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a bazel bug to track this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment. It seemed like a pretty intricate configuration, so I didn't try to reproduce it. I'd rather not report it upstream though without detailed instructions, since it's very unlikely to get fixed.

(Sorry I realize this sounds lazy; it's a consequence of not being able to spend adequate time on this).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Bazel bug is bazelbuild/bazel#12986

# file like this, but we haven't been able to reproduce the failure, so
# instead, we use this workaround.
if strip_prefix != "go":
fail("strip_prefix not supported")
ctx.download(
url = urls,
sha256 = sha256,
output = "go_sdk.tar.gz",
)
res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"])
if res.return_code:
fail("error extracting Go SDK:\n" + res.stdout + res.stderr)
ctx.delete("go_sdk.tar.gz")
else:
ctx.download_and_extract(
url = urls,
stripPrefix = strip_prefix,
sha256 = sha256,
)

def _local_sdk(ctx, path):
for entry in ["src", "pkg", "bin"]:
Expand Down