14

I've had Nvidia drivers work successfully before.

I switched to Nouveau for a little while since a game wasn't working properly, then switched back to Nvidia only to be notified of an error.

I have uninstalled and re-installed the Nvidia driver multiple times now but keep getting the same errors.

diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340
dpkg-divert: error: mismatch on package
  when removing 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 by libnvidia-gl-390'
  found 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340'
dpkg: error processing archive /tmp/apt-dpkg-install-JJFsm3/13-libnvidia-gl-390_390.48-0ubuntu3_amd64.deb (--unpack):
new libnvidia-gl-390:amd64 package pre-installation script subprocess returned error exit status 2

Errors were encountered while processing:
 /tmp/apt-dpkg-install-JJFsm3/13-libnvidia-gl-390_390.48-0ubuntu3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Installation method is sudo ubuntu-drivers autoinstall

  • 3
    Try running dpkg-divert --list | grep libGL.so.1 and see if it finds it. The try running sudo dpkg-divert --rename --remove --divert "/usr/lib/x86_64-linux-gnu/libGL.so.1.distrib" /usr/lib/x86_64-linux-gnu/libGL.so.1 Then try your installation again. – Terrance Aug 20 '18 at 14:27
  • @Terrance running dpkg-divert --list | grep libGL.so.1 does display one result. However running the second command didn't work out dpkg-divert: error: rename involves overwriting '/usr/lib/x86_64-linux-gnu/libGL.so.1' with different file '/usr/lib/x86_64-linux-gnu/libGL.so.1.distrib', not allowed – K. de Boer Aug 20 '18 at 14:40
  • Try completely removing libgl1 and nvidia-340. Those are the only two applications I can find that install that file. https://packages.ubuntu.com/search?suite=bionic&arch=any&mode=filename&searchon=contents&keywords=libGL.so.1 – Terrance Aug 20 '18 at 14:48
  • @Terrance removing libgl1 would remove 178 other packages including the gnome-shell. – K. de Boer Aug 20 '18 at 14:59
  • Then remove ANY NVIDIA drivers that you have installed right now. Did you upgrade your system recently like from 16.04 to 18.04? Sometimes the upgrades can cause problems that cannot be fixed other than just clean installing the OS again. It happened to me on my work system. – Terrance Aug 20 '18 at 15:08
  • 1
    @Terrance I have removed all packages with "nvidia" in them, dpkg -l | grep -i nvidia displays 0 results. I have not had a major updates yet since 18.04 is my first version. The only updates I've had are security patches, but I doubt that's the issue. – K. de Boer Aug 20 '18 at 15:14
  • Sorry, I was traveling here. One other thing, maybe try just removing the diversion and see if that works without the rename on it: sudo dpkg-divert --remove "/usr/lib/x86_64-linux-gnu/libGL.so.1.distrib" – Terrance Aug 20 '18 at 16:04
  • 1
    I believe sudo dpkg-divert --remove "/usr/lib/x86_64-linux-gnu/libGL.so.1" (without .distrib) fixed the issue. Can't see any errors on installation, going to try it out now. – K. de Boer Aug 20 '18 at 16:35
  • If that works, feel free to answer your own question so that others that might have the same issue can see how you fixed it. =) – Terrance Aug 20 '18 at 16:42

2 Answers2

9

Running sudo dpkg-divert --remove "/usr/lib/x86_64-linux-gnu/libGL.so.1" resolved my issue.

All thanks to @Terrance !

4

I had a raft of these problem with nvidia-340 diverts in Ubuntu 19.10; it seems to be a known bug with Ubuntu. package libnvidia-gl-390 (not installed) failed to install/upgrade: new libnvidia-gl-390:amd64 package pre-installation script subprocess returned error exit status 2 (NOT FIXED)

The workaround I did was #5, Yuri's improvement of Alexandre's suggestion

Try

# for FILE in $(dpkg-divert --list | grep nvidia-340 | awk '{print $3}'); do echo $FILE; done

first and choose the correct number for substring {print $3}

For example for Russian locale it will be $2:

# for FILE in $(dpkg-divert --list | grep nvidia-340 | awk '{print $2}'); do dpkg-divert --remove $FILE; done

brewmanz
  • 587