On EC2 instances using Amazon Linux 2, an outdated version of glibc is used: glibc 2.26. That is backed up by the FAQ for Amazon Linux 2. FAQ for Amazon Linux 2.
A set of core packages including systemd, GCC 7.3, Glibc 2.26, Binutils 2.29.1 that receive Long Term Support (LTS) from AWS.
Is there any way to upgrade to a newer version of Glibc, like 2.28? For background, I am trying to run a Python Docker image that is using glibc 2.28 and is running into conflicts since the 2.26 version is being used in the instance.
node.js - GLIBC_2.27 not found while installing Node on Amazon EC2 instance - Stack Overflow
node.js - GLIBC version issue while installing npm on Amazon Linux 2023 - Stack Overflow
Workaround for machines that do not have `glibc` >= 2.28
amazon ec2 - yum update errors with glibc dependency resolution - Stack Overflow
You have duplicate packages, and maybe other corruptions too. Try these commands:
package-cleanup --cleandupes # Removes duplicate packages
rpm --rebuilddb # Rebuilds RPM database
yum reinstall glibc nss-softokn-freebl vim-filesystem
When that works, see if yum is happy:
yum check dependencies
If it's complaining about dependencies, install them first.
Please try
sudo yum clean all
sudo yum update
Try installing the active LTS version instead of latest with nvm install 16 (instead of nvm install node) as per the examples.
This was tested on the docker image amazonlinux:2 and correlates to what AWS CDK supports (ref)
Update
LTS has moved on for node, however, as per @djvg's comment, note there is a limitation with amazon linux 2 on glibc, so if requiring node > 16 will need to move to newer amazon linux version, eg: https://github.com/amazonlinux/amazon-linux-2023/blob/main/Release-Notes-Amazon-Linux-2022.0.20220728.0.md
It seems like you are using v.18.0.0 which was the latest but not well-supported.
Try uninstalling that.
Copynvm uninstall 18.0.0
Install a version that is active.
Copynvm install 16.0.0
You should now be using v16 which should be well-supported.
The answer at:
Node.js 18 is compiled for glibc 2.28
is certainly correct although highly unsatisfying.
You cannot run the binary on your system because it relies on a version of glibc which is not available on your system.
$ docker run -it amazoncorretto:11 bash
bash-4.2# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
bash-4.2# rpm -q --provides glibc|grep -i libc.so
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.12)(64bit)
libc.so.6(GLIBC_2.13)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.16)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.18)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.2.6)(64bit)
libc.so.6(GLIBC_2.22)(64bit)
libc.so.6(GLIBC_2.23)(64bit)
libc.so.6(GLIBC_2.24)(64bit)
libc.so.6(GLIBC_2.25)(64bit)
libc.so.6(GLIBC_2.26)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.5)(64bit)
libc.so.6(GLIBC_2.6)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libc.so.6(GLIBC_2.9)(64bit)
It supports only up to GLIBC_2.26.
Also amazoncorretto:latest only supports up to glibc 2.26:
$ docker run -it amazoncorretto bash
bash-4.2# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
bash-4.2# rpm -q --provides glibc|grep -i libc.so
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.12)(64bit)
libc.so.6(GLIBC_2.13)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.16)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.18)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.2.6)(64bit)
libc.so.6(GLIBC_2.22)(64bit)
libc.so.6(GLIBC_2.23)(64bit)
libc.so.6(GLIBC_2.24)(64bit)
libc.so.6(GLIBC_2.25)(64bit)
libc.so.6(GLIBC_2.26)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.5)(64bit)
libc.so.6(GLIBC_2.6)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libc.so.6(GLIBC_2.9)(64bit)
You cannot update your glibc library because it is part of the Linux Kernel. It will be upgraded when you migrate to a newer Operating System Version.
The way to get it running on your system would be to rebuild it from the Source Code for your system and ideally package it for easily reproducible installation.
You might setup a docker image from amazoncorretto Base Image with the Packaging Environment set up.
An Package build on the Packaging Docker Host will be installable on all amazoncorretto:11 Systems.
Useful will be the pre-built .spec file which can be found at:
NodeJS .spec file
Then you only need to build your rpmbuild environment to create your installable NodeJS .rpm package.
AWS NodeJS Lambda Runner:
@Rich mentioned the public.ecr.aws/lambda/nodejs:18 AWS Lambda Runner image.
This is an image which is designed to run NodeJS tasks with the CMD dockerfile instruction at startup.
This actually might be fine for some single shot task (what it is designed for) or to startup directly a ExpressJS web app.
A downside is that you cannot independently update the NodeJS engine without upgrading the whole base image because the NodeJS engine is not installed as a system package.
$ docker run -it public.ecr.aws/lambda/nodejs:18
19 Jun 2023 09:53:51,148 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)
^C19 Jun 2023 09:54:26,776 [INFO] (rapid) Received signal signal=interrupt
19 Jun 2023 09:54:26,776 [INFO] (rapid) Shutting down...
19 Jun 2023 09:54:26,776 [WARNING] (rapid) Reset initiated: SandboxTerminated
19 Jun 2023 09:54:26,776 [INFO] (rapid) Stopping runtime domain
19 Jun 2023 09:54:26,776 [INFO] (rapid) Waiting for runtime domain processes termination
19 Jun 2023 09:54:26,776 [INFO] (rapid) Stopping operator domain
19 Jun 2023 09:54:26,776 [INFO] (rapid) Starting runtime domain
$ docker run --entrypoint bash -it public.ecr.aws/lambda/nodejs:18
bash-4.2# rpm -qa|grep -i node|wc -l
0
bash-4.2# node --version
v18.16.0
bash-4.2# npm --version
9.5.1
bash-4.2# cat /lambda-entrypoint.sh
#!/bin/sh
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
if [ $# -ne 1 ]; then
echo "entrypoint requires the handler name to be the first argument" 1>&2
exit 142
fi
export _HANDLER="$1"
RUNTIME_ENTRYPOINT=/var/runtime/bootstrap
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
exec /usr/local/bin/aws-lambda-rie $RUNTIME_ENTRYPOINT
else
exec $RUNTIME_ENTRYPOINT
fi
bash-4.2# ls -lah /usr/local/bin/aws-lambda-rie
-rwxr-xr-x 1 root root 5.6M Jun 12 13:21 /usr/local/bin/aws-lambda-rie
bash-4.2# ls -lah /etc/yum.repos.d
total 12K
drwxr-xr-x 2 root root 4.0K Jun 23 2022 .
drwxr-xr-x 1 root root 4.0K Jun 19 09:57 ..
-rw-r--r-- 1 root root 1003 Oct 26 2021 amzn2-core.repo
Building up on the answer by Bodo Hugo Barwich and the comment by Rich:
If you do not want to use the Docker image public.ecr.aws/lambda/nodejs:18 directly, you can copy node from that image to your own image via multi-stage build:
FROM public.ecr.aws/lambda/nodejs:18 as nodesource
FROM amazonlinux:2
ENV PATH="$PATH:/var/lang/bin"
COPY --from=nodesource /var/lang /var/lang
RUN npm i whatever
1, yum install yum-utils.noarch
2, package-cleanup --cleandupes
then it will tell you something like this
--> Finished Dependency Resolution Error: Trying to remove "yum", which is protected You could try using --skip-broken to work around the problem ———————————————————————————————————————————— in case
glibc-common-2.12-1.149.el6.x86_64 is a duplicate with glibc-common-2.12-1.132.el6_5.4.x86_64 glibc-common-2.12-1.149.el6.x86_64 has missing requires of glibc = ('0', '2.12', '1.149.el6')
3, yum check dependencies
yum check dependencies Loaded plugins: fastestmirror glibc-common-2.12-1.149.el6.x86_64 has missing requires of glibc = ('0', '2.12', '1.149.el6') Error: check ['dependencies']
4, rpm -e --nodeps glibc-common-2.12-1.149.el6.x86_64
5, yum clean all
6, yum update -y
I had this issue and resolved by:
sudo package-cleanup --cleandupes
and then run the update again:
sudo yum update