Getting an error while installing snap packages. Cannot read device key pair
Wondering why I'm unable to install snap packages, while in software center and using sudo snap install .... It gives me an error and I'm unable to discern what's causing it nor am I able to find others with the same issue.
So when I try to install it using terminal, I get the full error:
~$ sudo snap install pycharm-community --classic
error: cannot perform the following tasks:
- Download snap "pycharm-community" (103) from channel "stable" (cannot read device key pair: cannot find key pair)This is happening with every package I attempt to install, I'm just showing PyCharm as an example. Any pointers or anyone having the same issue that's found a resolution?
Update:
I have checked /var/lib/snapd/device/private-keys-v1 and it contains nothing.
I also ran:
sudo snap refresh core --edge
And got this error:
error: cannot perform the following tasks:
- Download snap "core" (6990) from channel "edge" (cannot read device key pair: cannot find key pair)I am unsure if I need to install from a repo or how to correctly install it.
12 Answers
Simply purge as described here with
sudo apt autoremove --purge snapd
Then install
sudo apt install snapd snapd-xdg-open
Sources:
How can I safely remove snap without breaking apparmor
3Try to check /var/lib/snapd/device/private-keys-v1 directory.
In my case it was empty. I was unable to find the key generation command, so as a workaround I copied private key from that directory of another system and it worked.
However, I'm not sure it's the best possible solution. Try snap apps now won't start with "cannot perform readlinkat()" error answer before using the workaround. I wanted to test it, but I couldn't reproduce key absence again (by renaming private-keys-v1 dir).