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

[Bug]: rules_nodejs installs prebuilt node binary which won't run without the proper shared libc.so version #3807

Open
srago opened this issue Dec 6, 2024 · 0 comments
Labels

Comments

@srago
Copy link

srago commented Dec 6, 2024

What happened?

Trying to use bazel to build buildbarn's bb-storage project on Ubuntu 18.04.6 LTS, the build fails because aspect_rules_js installs a rules_nodejs version that is looking for libc.so.6 from glibc version 2.28:

$ ldd rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node
rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node)
linux-vdso.so.1 (0x00007ffe5af95000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f64b9237000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f64b8eae000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f64b8b10000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f64b88f8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f64b86d9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f64b82e8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f64b943b000)

This version of Ubuntu uses glibc version 2.27:
$ ls -l /lib/x86_64-linux-gnu/libc.so.6
lrwxrwxrwx 1 root root 12 May 3 2022 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.27.so

So the node binary can't run:
$ rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node
rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node)

The problem is that the node binary is pre-built:
$ ls -l rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node
-rwxr-xr-x 1 sar sar 91342624 Jul 8 10:12 rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node

The date on the node binary is from July. It's December now. Bazel avoids problems like this by building all dependencies from source. If the projects took this approach, node would have been built with the native libraries on my Ubuntu system and would have avoided this failure case.

Note that I was able to work around this problem by pinning the version of node to one that happened to be built with the same glibc version as installed on my system:

bazel_dep(name = "rules_nodejs", version = "6.3.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "16.20.2")

(I determined this workaround by trial and error)

Version

Development (host) and target OS/architectures: Ubuntu 18.04.6 LTS x8
uname output:
Linux 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Output of bazel --version: 7.2.0

Version of rules_nodejs, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
bazel_dep(name = "aspect_rules_js", version = "2.1.0")

Language(s) and/or frameworks involved:
golang

How to reproduce

1) Check out https://github.com/buildbarn/bb-storage on an Ubuntu 18.04.6 Intel system
2) Run bazelisk build //...
3) Build fails with:

WARNING: /home/sar/buildbarn-ofc/bb-storage/BUILD.bazel:31:22: input 'package' of //:.aspect_rules_js/node_modules/@[email protected]/lc is a directory; dependency checking of directories is unsound
INFO: Analyzed 239 targets (0 packages loaded, 0 targets configured).
ERROR: /home/sar/buildbarn-ofc/bb-storage/BUILD.bazel:31:22: Running lifecycle hooks on npm package @pkgjs/[email protected] [for tool] failed: (Exit 1): lifecycle-hooks failed: error executing NpmLifecycleHook command (from target //:.aspect_rules_js/node_modules/@[email protected]/lc) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/aspect_rules_js~/npm/private/lifecycle/lifecycle-hooks_/lifecycle-hooks @pkgjs/parseargs ... (remaining 4 arguments skipped)
/home/sar/.cache/bazel/_bazel_sar/c16d908e4e511f3dfa714568d1218a6e/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/aspect_rules_js~/npm/private/lifecycle/lifecycle-hooks_/lifecycle-hooks.runfiles/_main/../rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /home/sar/.cache/bazel/_bazel_sar/c16d908e4e511f3dfa714568d1218a6e/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/aspect_rules_js~/npm/private/lifecycle/lifecycle-hooks_/lifecycle-hooks.runfiles/_main/../rules_nodejs~~node~nodejs_linux_amd64/bin/nodejs/bin/node)
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.830s, Critical Path: 0.20s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully

Any other information?

No response

@srago srago added the bug label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant