49

I am trying to install heroku cli using

sudo snap install heroku --classic

The command line says

error: cannot communicate with server: Post http://localhost/v2/apps: dial unix /run/snapd.socket: connect: no such file or directory

I tried systemctl status snapd.service this is the result :

snapd.service
   Loaded: masked (/dev/null; bad)  
   Active: inactive (dead)

I tried systemctl restart snapd.service it says:

Failed to restart snapd.service: Unit snapd.service is masked.

Any help on above problem in appreciated. Thanks.

Ravexina
  • 57,256

2 Answers2

47

Unmask the snapd.service:

sudo systemctl unmask snapd.service

Enable it:

sudo systemctl enable snapd.service

Start it:

sudo systemctl start snapd.service

Then try installing your desired app.

rluks
  • 181
Ravexina
  • 57,256
4

for a WSL-specific answer, I had this problem on WSL Ubuntu 24.04 pre-release where systemd was disabled, giving me errors like

$ snap install chromium
error: cannot communicate with server: Post "http://localhost/v2/snaps/chromium": dial unix /run/snapd.socket: connect: no such file or directory
$ sudo systemctl start snapd.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

and I fixed it by adding

[boot]
systemd=true

to /etc/wsl.conf , then restarting WSL :) (starting PowerShell as administrator and running wsl --shutdown), now Snap works great.

In comments to Ravexina's answer, I think this would solve the problem of Andy, Jortega, and Brian Z.. but i have no way to ping them.

hanshenrik
  • 565
  • 1
  • 6
  • 21