error: cannot communicate with server: Post http://localhost/v2/snaps/netbeans: dial unix /run/snapd.socket: connect: connection refused
copy the following commands one at a time and pate them in your terminal
sudo chmod o-w /var/lib/snapd/assertions/asserts-v0
sudo apt autoremove --purge snapd
$ sudo apt install snapd