Skip to content

Commit 5522ff8

Browse files
authored
fix: extract tar with correct environment (#2117)
* fix: extract tar with correct environment Fixes #2114 Updates the minimum version of bazel-lib. Users who don't update will see #2079 effectively reverted. * chore: accept new bazelrc presets
1 parent 6a9c4c1 commit 5522ff8

File tree

7 files changed

+56
-42
lines changed

7 files changed

+56
-42
lines changed

.aspect/bazelrc/correctness.bazelrc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test --test_verbose_timeout_warnings
2424
# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server
2525
# notices when a directory changes, if you have a directory listed in the srcs of some target.
2626
# Recommended when using
27-
# [copy_directory](https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_directory.md) and
27+
# [copy_directory](https://github.com/bazel-contrib/bazel-lib/blob/main/docs/copy_directory.md) and
2828
# [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories
2929
# inputs to copy_directory actions.
3030
# Docs: https://bazel.build/reference/command-line-reference#flag--host_jvm_args
@@ -42,17 +42,6 @@ test --incompatible_exclusive_test_sandboxed
4242
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env
4343
build --incompatible_strict_action_env
4444

45-
# Propagate tags from a target declaration to the actions' execution requirements.
46-
# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]`
47-
# get propagated to actions created by the rule.
48-
# Without this option, you rely on rules authors to manually check the tags you passed
49-
# and apply relevant ones to the actions they create.
50-
# See https://github.com/bazelbuild/bazel/issues/8830 for details.
51-
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation
52-
build --experimental_allow_tags_propagation
53-
fetch --experimental_allow_tags_propagation
54-
query --experimental_allow_tags_propagation
55-
5645
# Do not automatically create `__init__.py` files in the runfiles of Python targets. Fixes the wrong
5746
# default that comes from Google's internal monorepo by using `__init__.py` to delimit a Python
5847
# package. Precisely, when a `py_binary` or `py_test` target has `legacy_create_init` set to `auto (the

.aspect/bazelrc/performance.bazelrc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache.
2-
# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where
3-
# Bazel doesn't write to the local disk cache as it treats as a remote cache.
4-
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_remote_results_ignore_disk
5-
build --incompatible_remote_results_ignore_disk
6-
71
# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
82
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
93
# build.
104
# No longer experimental in Bazel 6: https://github.com/bazelbuild/bazel/commit/c1a95501a5611878e5cc43a3cc531f2b9e47835b
115
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
126
build --experimental_reuse_sandbox_directories
137

14-
# Do not build runfiles symlink forests for external repositories under
15-
# `.runfiles/wsname/external/repo` (in addition to `.runfiles/repo`). This reduces runfiles &
16-
# sandbox creation times & prevents accidentally depending on this feature which may flip to off by
17-
# default in the future. Note, some rules may fail under this flag, please file issues with the rule
18-
# author.
19-
# Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles
20-
build --nolegacy_external_runfiles
8+
# Avoid creating a runfiles tree for binaries or tests until it is needed.
9+
# Docs: https://bazel.build/reference/command-line-reference#flag--build_runfile_links
10+
# See https://github.com/bazelbuild/bazel/issues/6627
11+
#
12+
# This may break local workflows that `build` a binary target, then run the resulting program
13+
# outside of `bazel run`. In those cases, the script will need to call
14+
# `bazel build --build_runfile_links //my/binary:target` and then execute the resulting program.
15+
build --nobuild_runfile_links
16+
17+
# Needed prior to Bazel 8; see
18+
# https://github.com/bazelbuild/bazel/issues/20577
19+
coverage --build_runfile_links

.github/workflows/bazel6.bazelrc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,35 @@ build --noexperimental_action_cache_store_output_metadata
2020
# when local debugging.
2121
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185
2222
# NB: This flag is in bazel6.bazelrc as when used in Bazel 7 is has been observed to break
23-
# "build without the bytes" --remote_download_outputs=toplevel. See https://github.com/aspect-build/bazel-lib/pull/711
23+
# "build without the bytes" --remote_download_outputs=toplevel. See https://github.com/bazel-contrib/bazel-lib/pull/711
2424
# for more info.
2525
build --noexperimental_check_output_files
2626
fetch --noexperimental_check_output_files
2727
query --noexperimental_check_output_files
28+
29+
# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache.
30+
# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where
31+
# Bazel doesn't write to the local disk cache as it treats as a remote cache.
32+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_remote_results_ignore_disk
33+
# NB: This flag is in bazel6.bazelrc because it became a no-op in Bazel 7 and has been removed
34+
# in Bazel 8.
35+
build --incompatible_remote_results_ignore_disk
36+
37+
# Propagate tags from a target declaration to the actions' execution requirements.
38+
# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]`
39+
# get propagated to actions created by the rule.
40+
# Without this option, you rely on rules authors to manually check the tags you passed
41+
# and apply relevant ones to the actions they create.
42+
# See https://github.com/bazelbuild/bazel/issues/8830 for details.
43+
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation
44+
build --experimental_allow_tags_propagation
45+
fetch --experimental_allow_tags_propagation
46+
query --experimental_allow_tags_propagation
47+
48+
# Do not build runfiles symlink forests for external repositories under
49+
# `.runfiles/wsname/external/repo` (in addition to `.runfiles/repo`). This reduces runfiles &
50+
# sandbox creation times & prevents accidentally depending on this feature which may flip to off by
51+
# default in the future. Note, some rules may fail under this flag, please file issues with the rule
52+
# author.
53+
# Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles
54+
build --nolegacy_external_runfiles

.github/workflows/bazel7.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ common --check_direct_dependencies=off
1313
# build.
1414
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
1515
build --reuse_sandbox_directories
16+
17+
# Do not build runfiles symlink forests for external repositories under
18+
# `.runfiles/wsname/external/repo` (in addition to `.runfiles/repo`). This reduces runfiles &
19+
# sandbox creation times & prevents accidentally depending on this feature which may flip to off by
20+
# default in the future. Note, some rules may fail under this flag, please file issues with the rule
21+
# author.
22+
# Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles
23+
build --nolegacy_external_runfiles

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module(
99

1010
# Lower-bounds (minimum) versions for direct runtime dependencies.
1111
# Do not bump these unless rules_js requires a newer version to function.
12-
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1")
12+
bazel_dep(name = "aspect_bazel_lib", version = "2.14.0")
1313
bazel_dep(name = "bazel_features", version = "1.9.0")
1414
bazel_dep(name = "bazel_skylib", version = "1.5.0")
1515
bazel_dep(name = "platforms", version = "0.0.5")

js/repositories.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def rules_js_dependencies():
2323

2424
http_archive(
2525
name = "aspect_bazel_lib",
26-
sha256 = "f93d386d8d0b0149031175e81df42a488be4267c3ca2249ba5321c23c60bc1f0",
27-
strip_prefix = "bazel-lib-2.9.1",
28-
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v2.9.1/bazel-lib-v2.9.1.tar.gz",
26+
sha256 = "40ba9d0f62deac87195723f0f891a9803a7b720d7b89206981ca5570ef9df15b",
27+
strip_prefix = "bazel-lib-2.14.0",
28+
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v2.14.0/bazel-lib-v2.14.0.tar.gz",
2929
)

npm/private/npm_package_store.bzl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ If set, takes precendance over the package version in the NpmPackageInfo src.
154154
"verbose": attr.bool(
155155
doc = """If true, prints out verbose logs to stdout""",
156156
),
157-
"_macos_constraint": attr.label(default = "@platforms//os:macos"),
158157
}
159158

160159
def _npm_package_store_impl(ctx):
@@ -230,7 +229,6 @@ def _npm_package_store_impl(ctx):
230229
# tar to strip one directory level. Some packages have directory permissions missing
231230
# executable which make the directories not listable (pngjs@5.0.0 for example).
232231
bsdtar = ctx.toolchains["@aspect_bazel_lib//lib:tar_toolchain_type"]
233-
is_macos = ctx.target_platform_has_constraint(ctx.attr._macos_constraint[platform_common.ConstraintValueInfo])
234232
tar_exclude_package_contents = (["--exclude"] + ctx.attr.exclude_package_contents) if ctx.attr.exclude_package_contents else []
235233
ctx.actions.run(
236234
executable = bsdtar.tarinfo.binary,
@@ -250,17 +248,10 @@ def _npm_package_store_impl(ctx):
250248
],
251249
mnemonic = "NpmPackageExtract",
252250
progress_message = "Extracting npm package {}@{}".format(package, version),
253-
# Workaround https://github.com/bazelbuild/bazel-central-registry/issues/2256
251+
254252
# Always override the locale to give better hermeticity.
255-
# See https://github.com/bazelbuild/rules_java/blob/767e4410850453a10ccf89aa1cededf9de05c72e/toolchains/utf8_environment.bzl
256-
# and https://github.com/libarchive/libarchive/blob/65196fdd1a385f22114f245a9002ee8dc899f2c4/tar/bsdtar.c#L192
257-
env = {
258-
"LC_ALL":
259-
# # macOS doesn't have the C.UTF-8 locale, but en_US.UTF-8 is available and works the same way.
260-
"en_US.UTF-8" if is_macos else
261-
# The default UTF-8 locale on all recent Linux distributions. It is also available in Cygwin and MSYS2.
262-
"C.UTF-8",
263-
},
253+
# See https://github.com/aspect-build/rules_js/issues/2039
254+
env = getattr(bsdtar.tarinfo, "default_env", {}),
264255
)
265256
else:
266257
copy_directory_bin_action(

0 commit comments

Comments
 (0)