2

I'm just doing my usual weekly update of packages on my Ubuntu machines, and Something Went Wrong (TM). I'm seeing this in the output of "sudo apt upgrade"

Setting up linux-headers-4.15.0-36-generic (4.15.0-36.39) ...
/etc/kernel/header_postinst.d/dkms:
Error! Could not locate dkms.conf file.
File:  does not exist.
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 4
dpkg: error processing package linux-headers-4.15.0-36-generic (--configure):
 installed linux-headers-4.15.0-36-generic package post-installation script subprocess returned error exit status 1

I've seen other posts about fixing missing dkms stuff, but they all seem to involve deleting files or directories, and I'm a little hesitant to do that with kernel stuff.

I tried:

sudo apt --fix-broken install

but that seems to complain about the same missing file.

Is there some invocation that will let Ubuntu fix this error?

UPDATE: nothing seems to be working to fix this. sudo apt upgrade and sudo apt dist-upgrade both try to install new kernels, but then return

/etc/kernel/postinst.d/dkms: Error! Could not locate dkms.conf file. File: does not exist.

followed by

Errors were encountered while processing: linux-headers-4.15.0-36-generic linux-headers-4.15.0-38-generic linux-headers-generic linux-generic linux-image-4.15.0-36-generic linux-image-4.15.0-38-generic E: Sub-process /usr/bin/dpkg returned an error code (1)

I'm starting to think I'm completely screwed and will have no choice but to re-install Ubuntu (again. sigh.)

Chris Curvey
  • 1,643

1 Answers1

4

Took a while to find this, but I tracked it down.

First, run this command to find the offending "thing"

for i in /var/lib/dkms/*/[^k]*/source; do [ -e "$i" ] || echo "$i";done

In my case, it spit out

/var/lib/dkms/nvidia-340/340.106/source

Take a deep breath and get rid of that directory

sudo rm -Rf /var/lib/dkms/nvidia-340/340.106/source

Now run your updates:

sudo apt upgrade

Footnotes/Credits:

https://bbs.archlinux.org/viewtopic.php?id=151965

https://8thstring.blogspot.com/2012/01/error-could-not-locate-dkmsconf-file.html

Chris Curvey
  • 1,643