I'm getting "installed rtl8821ce-dkms package post-installation script subprocess returned error exit status 3" error

I ran sudo dpkg --configure -a and got this message:

Setting up rtl8821ce-dkms (5.5.2.1-0ubuntu4~20.04.3) ...
Removing old rtl8821ce-5.5.2.1 DKMS files...
Loading new rtl8821ce-5.5.2.1 DKMS files...
Error! DKMS tree already contains: rtl8821ce-5.5.2.1
You cannot add the same module/version combo more than once.
dpkg: error processing package rtl8821ce-dkms (--configure):
 installed rtl8821ce-dkms package post-installation script subprocess returned error exit status 3
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
 rtl8821ce-dkms

Consequently, I can't use the Wi-Fi. I can't run the VirtualBox. I have tried reinstalling Ubuntu 20.04, but it's still the same. I have tried several ways all day but to no avail.

I ran sudo apt-get autoremove and got this message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up rtl8821ce-dkms (5.5.2.1-0ubuntu4~20.04.3) ...
Removing old rtl8821ce-5.5.2.1 DKMS files...
Loading new rtl8821ce-5.5.2.1 DKMS files...
Error! DKMS tree already contains: rtl8821ce-5.5.2.1
You cannot add the same module/version combo more than once.
dpkg: error processing package rtl8821ce-dkms (--configure):
 installed rtl8821ce-dkms package post-installation script subprocess returned error exit status 3
Errors were encountered while processing:
 rtl8821ce-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)`

I ran sudo apt-get install -f and got this message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up rtl8821ce-dkms (5.5.2.1-0ubuntu4~20.04.3) ...
Removing old rtl8821ce-5.5.2.1 DKMS files...
Loading new rtl8821ce-5.5.2.1 DKMS files...
Error! DKMS tree already contains: rtl8821ce-5.5.2.1
You cannot add the same module/version combo more than once.
dpkg: error processing package rtl8821ce-dkms (--configure):
 installed rtl8821ce-dkms package post-installation script subprocess returned error exit status 3
Errors were encountered while processing:
 rtl8821ce-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

What should I do?


You need to reinstall the package after removing it from your system. Reinstalling solved the error in many of the systems I have tried it. So run the following commands:

sudo apt-get autoremove
sudo dpkg --configure -a
sudo apt-get install -f
sudo apt remove rtl8821ce-dkms
git clone https://github.com/tomaspinho/rtl8821ce
cd rtl8821ce
chmod +x dkms-install.sh
chmod +x dkms-remove.sh
make
sudo make install
sudo ./dkms-install.sh

Then reboot.