I am trying to install nginx-module-otel on RHEL9 but it can not find libcares.so.2 and is failing as follows:
[root@6c96e0f290a0 c-ares-1.34.4]# dnf install nginx-module-otel
Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.
This system is not registered with an entitlement server. You can use subscription-manager to register.
nginx stable repo 56 kB/s | 41 kB 00:00
Error:
Problem: cannot install the best candidate for the job
- nothing provides libcares.so.2()(64bit) needed by nginx-module-otel-1:1.26.2+0.1.0-1.el9.ngx.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
I built c-ares from source and updated the library cache but for some reason dnf
can not find the shared object. In the "Debug Info" section you can see that the lib files are available, and I have also attached the steps needed to reproduce the error.
docker run -it --name ubi registry.access.redhat.com/ubi9/ubi:9.0.0-1703 /bin/bash
# Install development tools
dnf install -y wget gcc gcc-c++ make
# Build c-ares from source
wget "https://github.com/c-ares/c-ares/releases/download/v1.34.4/c-ares-1.34.4.tar.gz"
tar xzf c-ares-1.34.4.tar.gz
cd c-ares-1.34.4
./configure --prefix=/usr --libdir=/lib64
make
make install
ldconfig
# [Optional] Install re2
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf config-manager --set-enabled epel
/usr/bin/crb enable
dnf install -y re2-devel
# Create nginx repo file
cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
# Import nginx signing key
rpm --import https://nginx.org/keys/nginx_signing.key
# Install otel
dnf install nginx-module-otel
[root@6c96e0f290a0 c-ares-1.34.4]# ls -l /lib64/*ares*
-rw-r--r-- 1 root root 2808910 Jan 20 08:49 /lib64/libcares.a
-rwxr-xr-x 1 root root 959 Jan 20 08:49 /lib64/libcares.la
lrwxrwxrwx 1 root root 18 Jan 20 08:49 /lib64/libcares.so -> libcares.so.2.19.3
lrwxrwxrwx 1 root root 18 Jan 20 08:49 /lib64/libcares.so.2 -> libcares.so.2.19.3
-rwxr-xr-x 1 root root 1179640 Jan 20 08:49 /lib64/libcares.so.2.19.3
[root@6c96e0f290a0 c-ares-1.34.4]# ls -l /usr/lib64/*ares*
-rw-r--r-- 1 root root 2808910 Jan 20 08:49 /usr/lib64/libcares.a
-rwxr-xr-x 1 root root 959 Jan 20 08:49 /usr/lib64/libcares.la
lrwxrwxrwx 1 root root 18 Jan 20 08:49 /usr/lib64/libcares.so -> libcares.so.2.19.3
lrwxrwxrwx 1 root root 18 Jan 20 08:49 /usr/lib64/libcares.so.2 -> libcares.so.2.19.3
-rwxr-xr-x 1 root root 1179640 Jan 20 08:49 /usr/lib64/libcares.so.2.19.3
[root@6c96e0f290a0 c-ares-1.34.4]# ldconfig -p | grep ares
libcares.so.2 (libc6,x86-64) => /lib64/libcares.so.2
libcares.so (libc6,x86-64) => /lib64/libcares.so
[root@6c96e0f290a0 c-ares-1.34.4]# ldconfig -v | grep ares
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Path `/usr/lib64' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Can't stat /usr/libx32: No such file or directory
libcares.so.2 -> libcares.so.2.19.3
Packaging c-ares as an RPM then installing it worked.
# Install build tools
sudo dnf install -y rpm-build gcc make autoconf automake libtool
# Set up rpmbuild directories:
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
# Download c-ares source:
cd ~/rpmbuild/SOURCES
curl -LO https://github.com/c-ares/c-ares/releases/download/v1.34.4/c-ares-1.34.4.tar.gz
Create a spec file (~/rpmbuild/SPECS/c-ares.spec) that builds and packages c-ares:
Name: c-ares
Version: 1.34.4
Release: 1%{?dist}
Summary: Library for asynchronous DNS requests
License: MIT
URL: https://c-ares.org/
Source0: c-ares-1.34.4.tar.gz
BuildRequires: gcc, make, autoconf, automake, libtool
%description
c-ares is a C library that performs DNS requests asynchronously.
%package devel
Summary: Development files for c-ares
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
%description devel
This package contains development files (headers, static libs, .pc file)
for c-ares.
%prep
%setup -q
%build
autoreconf -fi
%configure --prefix=%{_prefix} --libdir=%{_libdir}
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%files
%{_libdir}/libcares.so.2*
%files devel
%{_includedir}/ares*.h
%{_libdir}/libcares.so
%{_libdir}/libcares.a
%{_libdir}/libcares.la
%{_libdir}/pkgconfig/libcares.pc
Build and install:
cd ~/rpmbuild
rpmbuild -ba SPECS/c-ares.spec
sudo dnf localinstall RPMS/x86_64/c-ares-1.34.4-1.el9.x86_64.rpm \
RPMS/x86_64/c-ares-devel-1.34.4-1.el9.x86_64.rpm
Then proceed with the steps to add nginx repo, signing key, and installing nginx-module-otel
.