Skip to content

Commit d7cd5d6

Browse files
committed
fix: don't unpack empty gems
1 parent db7103a commit d7cd5d6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ruby/private/bundle_fetch.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ def _get_gem_executables(repository_ctx, gem, cache_path):
7979
so some exotic gems might not work correctly.
8080
"""
8181
executables = []
82-
repository_ctx.symlink(cache_path + "/" + gem.filename, gem.filename + ".tar")
82+
gem_filepath = cache_path + "/" + gem.filename
83+
84+
# Some gems are empty (e.g. date-4.2.1-java), so we should not try to unpack them.
85+
# Metadata has "files: []" which we could use to detect this, but Bazel cannot
86+
# decompress `.gz` files (see above).
87+
if len(repository_ctx.read(gem_filepath)) == 4096:
88+
return executables
89+
90+
repository_ctx.symlink(gem_filepath, gem.filename + ".tar")
8391
repository_ctx.extract(gem.filename + ".tar", output = gem.full_name)
8492
data = "/".join([gem.full_name, "data"])
8593
repository_ctx.extract("/".join([gem.full_name, "data.tar.gz"]), output = data)

0 commit comments

Comments
 (0)