Kernel update makes impossible to purge nvidia-*

Hi,
Usually, I changed my driver version whith

sudo apt-get purge nvidia-*
sudo apt-get install nvidia-346 nvidia-settings nvidia-prime
sudo apt-get purge nvidia-*
sudo apt-get install nvidia-372 nvidia-settings nvidia-prime
....

But then, I upgraded my kernel with nvidia driver installed :

sudo apt-get purge nvidia-*
sudo apt-get install nvidia-346 nvidia-settings nvidia-prime
sudo apt-get install linux-generic-lts-xenial

And now, purging nvidia-* is not possible anymore, sudo apt-get purge nvidia-* gives (same problem with remove):

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package nvidia-bug-report.log
E: Couldn't find any package by regex 'nvidia-bug-report.log'
E: Unable to locate package nvidia-bug-report.log.gz
E: Couldn't find any package by regex 'nvidia-bug-report.log.gz'

Is isn’t much of a problem as I can still remove package individually, but what is happening ?

Looks like the wildcard is matching the nvidia-bug-report.log.gz file in the directory your running the command from, try

cd /
sudo apt-get purge nvidia-*
1 Like

Yes thats it ! Strange, as it usually don’t depends on the directory…
thanks

Locate nvidia-bug-report.log.gz on your /home/user folder, and delete it

Note this issue is still occurring 18 June 2020, and requires the above workaround:

cd /
sudo apt-get purge nvidia-*

Your shell is doing glob expansion before actually executing the command. This is the expected behavior. To prevent that, you could do:
sudo apt purge 'nvidia-*'