Search code examples
ubuntunvidiaaptapt-getdpkg

apt-get fails to install and remove package


I wanted to install cuda on my ubuntu 18.04, and also install nvidia-driver-450. but sth was wrong. when I restart my laptop, gui did'nt load and a command line appear. first i run sudo apt-get install -f . but it raise error

Errors where encountered while proccessing:
/var/cache/apt/archives/libnvidia-gl-450_450.57-0ubuntu~0.10.04.2_i306.deb
/var/cache/apt/archives/libnvidia-gl-450_450.57-0ubuntu~0.10.04.2_amd64.deb
E: Subproccess /var/bin/dpkg returned an error code (1)

then i run sudo dpkg --configure -a and it raised:

enter image description here

then i test sudo apt remove --purge <package> and raise error:

enter image description here

thanks for your helps!!


Solution

  • I could solve it after 3 days serching. first i ran

    LC_MESSAGES=C dpkg-divert --list 'nvidia-340' | sed -nre 's/^diversion of (.) to ./\1/p' | xargs -rd'\n' -n1 -- sudo dpkg-divert --remove

    sudo apt --fix-broken install

    then:

    sudo apt purge nvidia*

    and reboot.