Running Neovim on older Linux boxes

If you're stuck on a 10-year old Linux machine at work, but still want to run the latest version of Neovim that just released, this guide may help you.

Neovim 0.10.0 was compiled with a newer version of glibc, so running it on Redhat 7 or CentOS 7 may lead to this:

./nvim: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./nvim)
./nvim: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by ./nvim)

Updating glibc for the entire system or adding a new version to LD_LIBRARY_PATH is not really an option since it will mess up your entire system.

Fortunatelly there is a way to save the situation using a tool called patchelf.

This amazing tool can set the path to a newer glibc library right inside the nvim executable.

To use it, we first need to compile a newer version of glibc from source. We will use a local folder to store the library, using the --prefix flag

wget http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
tar -xzvf glibc-2.18.tar.gz
cd glibc-2.18
mkdir build 
cd build
../configure --prefix=/home/mihai/glibc
make
make install

We then run patchelf to patch Neovim

tar -xzvf nvim-linux64.tar.gz
cd nvim-linux64/bin
cp nvim nvim.bak
patchelf --set-interpreter /home/mihai/glibc/lib/ld-linux-x86-64.so.2 --set-rpath /home/mihai/glibc/lib:/usr/lib64 ./nvim

Note that the value of --set-rpath needs to include the location of your compiled glibc first, then the location of system libraries, in this case /usr/lib64.

2024-05-17

Comments

jun it's easier just build nvim from source