Nvidia driver installation keeps failing, diversion issues

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

All thanks to @Terrance !


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