Saturday, 13 August 2016

RHEL5/OL5/Centos5 - vi not working for non root user "vim: error while loading shared libraries: libgpm.so.1"

SYMPTOMS

 For non-root user "vi" editor will report errors with the shared library
 $vi test
 vim: error while loading shared libraries: libgpm.so.1: cannot open shared object file: No such file or directory

CAUSE

Shared library "libgpm.so.1" is required for the vim editor and the same is not found as per the ldd command:

#  ldd /usr/bin/vim
linux-vdso.so.1 => (0x00007fffd5ffd000)
libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x0000003a71600000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003a60400000)
libacl.so.1 => /lib64/libacl.so.1 (0x0000003a5f000000)
libgpm.so.1 => not found                            <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
libperl.so => /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so (0x0000003a60800000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003a67000000)
libutil.so.1 => /lib64/libutil.so.1 (0x0000003a6c600000)
libc.so.6 => /lib64/libc.so.6 (0x0000003a5e800000)
libm.so.6 => /lib64/libm.so.6 (0x0000003a5ec00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003a5f400000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003a5f800000)
libsepol.so.1 => /lib64/libsepol.so.1 (0x0000003a60000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003a5e400000)
libattr.so.1 => /lib64/libattr.so.1 (0x0000003a63000000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003a62c00000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003a71200000)



For non root users, alias is set for the "vi" command, so it invokes the vim and report the above error in the absence of "libgpm.so.1" file or gpm package.
Alias rule won't be imposed for the root user or user id less then 100 due to which root user can able to do "vi" without the above error, but "vim" will fail for root user.

Following is the configuration which defines the alias for vi.

# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
tmpid=$(/usr/bin/id -u)
[ "$tmpid" = "" ] && tmpid=0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
[ $tmpid -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi

# which vi
alias vi='vim'
      /usr/bin/vim

Shared library "libgpm.so.1" required to use vim editor is available from gpm RPM package.

SOLUTION

Make sure gpm RPM package is installed:

# rpm -qf /usr/lib64/libgpm.so.1
gpm-1.20.1-74.1.0.1

# rpm -qa |grep gpm

Install it by:

# yum install gpm

No comments:

Post a Comment