I am running apt --fix-broken install. I get:

dpkg-divert: error: mismatch on package when removing 'diversion of /usr/lib/i386-linux-gnu.so.1 by libnvidia-gl-390'
found 'diversion of /usr/lib/i386-linux-gnu.so.1 to /usr/lib/i386-linux-gnu.so.1.distrib by nvidia-340

(also other stuff but let's take it one step at a time)

Aha! Thinks I; I'll remove nvidia-340 then, except ...

apt remove nvidia-340
Package 'nvidia-340' is not installed, so not removed

How do I remove diversion errors from packages that look to me at though they aren't installed? What am I missing?

2 Answers 2


Looks like this is a 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


# 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

  • This didn't work for me, it only echo the content of the file or the do command is not recognized.
    – Boorhin
    Commented Aug 17, 2022 at 18:03
  • 1
    Worked for me. Ubuntu 20.
    – Vikram Ray
    Commented Jun 5 at 16:23

I posted a more laborious answer to the bug report, you can find here https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-390/+bug/1768050/comments/8

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .