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

fix: override the locale when running bsdtar actions #2044

Merged
merged 7 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ js/private/test/js_run_devserver/package.json=-381403605
js/private/worker/src/package.json=-1243560410
npm/private/test/npm_package/package.json=-1991705133
npm/private/test/npm_package_publish/package.json=-646566766
npm/private/test/package.json=248936204
npm/private/test/package.json=606610593
npm/private/test/vendored/is-odd/package.json=1041695223
npm/private/test/vendored/lodash-4.17.21.tgz=-1206623349
npm/private/test/vendored/semver-max/package.json=578664053
package.json=1510979981
pnpm-lock.yaml=-1005187097
pnpm-lock.yaml=1372779172
pnpm-workspace.yaml=-1123429050
12 changes: 12 additions & 0 deletions npm/private/npm_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ If set, takes precendance over the package version in the NpmPackageInfo src.
"verbose": attr.bool(
doc = """If true, prints out verbose logs to stdout""",
),
"_macos_constraint": attr.label(default = "@platforms//os:macos"),
}

def _npm_package_store_impl(ctx):
Expand Down Expand Up @@ -223,6 +224,7 @@ def _npm_package_store_impl(ctx):
# tar to strip one directory level. Some packages have directory permissions missing
# executable which make the directories not listable ([email protected] for example).
bsdtar = ctx.toolchains["@aspect_bazel_lib//lib:tar_toolchain_type"]
is_macos = ctx.target_platform_has_constraint(ctx.attr._macos_constraint[platform_common.ConstraintValueInfo])
ctx.actions.run(
executable = bsdtar.tarinfo.binary,
inputs = depset(direct = [src], transitive = [bsdtar.default.files]),
Expand All @@ -240,6 +242,16 @@ def _npm_package_store_impl(ctx):
],
mnemonic = "NpmPackageExtract",
progress_message = "Extracting npm package {}@{}".format(package, version),
# Workaround https://github.com/bazelbuild/bazel-central-registry/issues/2256
# Always override the locale to give better hermeticity.
# See https://github.com/bazelbuild/rules_java/blob/767e4410850453a10ccf89aa1cededf9de05c72e/toolchains/utf8_environment.bzl
env = {
"LC_CTYPE":
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
# # macOS doesn't have the C.UTF-8 locale, but en_US.UTF-8 is available and works the same way.
"en_US.UTF-8" if is_macos else
# The default UTF-8 locale on all recent Linux distributions. It is also available in Cygwin and MSYS2.
"C.UTF-8",
},
)
else:
copy_directory_bin_action(
Expand Down
3 changes: 3 additions & 0 deletions npm/private/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ build_test(
# puppeteer: has a bin entry in the transitive closure with two segments: @puppeteer/browsers in https://unpkg.com/@puppeteer/[email protected]/package.json
# segfault-handler: has a node-gyp install step
":node_modules",

# @fastify/send (@3.3.0) contains spaces and a ☃ character in paths
":node_modules/@fastify/send",
],
)

Expand Down
1 change: 1 addition & 0 deletions npm/private/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"// devDependencies": "test linking & building 3rd party npm packages with problematic postinstall",
"devDependencies": {
"hello": "https://gitpkg.vercel.app/EqualMa/gitpkg-hello/packages/hello",
"@fastify/send": "3.3.0",
"@figma/nodegit": "^0.28.0-figma.2",
"@kubernetes/client-node": "https://github.com/kubernetes-client/javascript#bd6ab5810d013103d244ddaebe0304649c012b38",
"@plotly/regl": "2.1.2",
Expand Down
3,689 changes: 1,858 additions & 1,831 deletions npm/private/test/snapshots/bzlmod/npm_defs.bzl

Large diffs are not rendered by default.

3,689 changes: 1,858 additions & 1,831 deletions npm/private/test/snapshots/wksp/npm_defs.bzl

Large diffs are not rendered by default.

211 changes: 211 additions & 0 deletions npm/private/test/snapshots/wksp/repositories.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading