After system repair, snapd service is not running/fails to restart

I have kubuntu 20.10 that was moved from a bad hard disk to a new one. After I managed to get the system running, I have the following problem: any reference to snap (eg. snap refresh) results in the following error:

error: cannot communicate with server: Post http://localhost/v2/snaps: dial unix /run/snapd.socket: connect: connection refused

As suggested in various other places, I tried to restart snap: systemctl restart snapd

Which did not work:

Job for snapd.service failed because the control process exited with error code. See "systemctl status snapd.service" and "journalctl -xe" for details.

systemctl status snapd

systemd[1]: snapd.service: Scheduled restart job, restart counter is at 5. systemd[1]: Stopped Snap Daemon. systemd[1]: snapd.service: Start request repeated too quickly. systemd[1]: snapd.service: Failed with result 'exit-code'. systemd[1]: Failed to start Snap Daemon. systemd[1]: snapd.service: Triggering OnFailure= dependencies.

journalctl -xe

Journal file /var/log/journal/01b4740d96764e08a9d72db26b6152ca/[email protected]~ is truncated, ignoring file. A start job for unit snapd.service has finished with a failure.

The job identifier is 10214 and the job result is failed. snapd.socket: Failed with result 'service-start-limit-hit'. Subject: Unit failed Defined-By: systemd Support: http://www.ubuntu.com/support

The unit snapd.socket has entered the 'failed' state with result 'service-start-limit-hit'. snapd.service: Triggering OnFailure= dependencies.
systemd[1]: Starting Failure handling of the snapd snap... Subject: A start job for unit snapd.failure.service has begun execution Defined-By: systemd Support: http://www.ubuntu.com/support A start job for unit snapd.failure.service has begun execution. The job identifier is 10359. snapd.failure.service: Succeeded. Subject: Unit succeeded Defined-By: systemd Support: http://www.ubuntu.com/support The unit snapd.failure.service has successfully entered the 'dead' state. Finished Failure handling of the snapd snap. Subject: A start job for unit snapd.failure.service has finished successfully Defined-By: systemd Support: http://www.ubuntu.com/support A start job for unit snapd.failure.service has finished successfully. The job identifier is 10359.

Any ideas how to get it fixed?

Additional info:

The /var partition was recovered from a faulty drive with ddrescue, had errors fixed by e2fsck after recovery.


A brute force fix:

sudo apt purge snapd snap
sudo apt install snapd snap

Followed by manual re-installation of all snaps.

If anyone can suggest a better fix, you are welcome.