40

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
  • 54,268
  • 25
  • 157
  • 179
swasthik nayak
  • 503
  • 1
  • 4
  • 4
  • 2
    Related: [systemctl, how to unmask](https://askubuntu.com/questions/804946/systemctl-how-to-unmask) – Ravexina Jul 11 '20 at 07:43
  • 3
    For anyone seeing this issue with Windows Subsystem for Linux (WSL) see - https://github.com/microsoft/WSL/issues/5126 Run this before attempting a snap install - it should work: `sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig` `sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target` `exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME` – Chris Halcrow Mar 24 '22 at 04:10
  • 1
    Add these lines to the /etc/wsl.conf (note you will need to run your editor with sudo `[boot] systemd=true` after that, you should run wsl.exe --shutdown – Felipe Pereira Mar 16 '23 at 20:11

1 Answers1

35

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
  • 171
  • 6
Ravexina
  • 54,268
  • 25
  • 157
  • 179
  • 10
    I am running WSL based on Ubuntu Linux, And running these instructions gives error after last command: System has not been booted with systemd as init system (PID 1). Can't operate. – Andy Aug 17 '21 at 14:55
  • 13
    If you are using WSL then this answer is not applicable to your situation. Basically because there is no `systemd` on WSL in the first place. However [this](https://github.com/microsoft/WSL/issues/5126) might be helpful to you. – Ravexina Aug 17 '21 at 16:31
  • 15
    I am inside a docker image of ubuntu. Running `systemctl start snapd.service` returns `System has not been booted with systemd as init system (PID 1). Can't operate.` – Jortega Sep 13 '21 at 23:00
  • @Jortega Did you ever find a solution? I'm thinking based on [other discussions](https://forum.snapcraft.io/t/installing-and-running-snaps-without-systemd/3949/20) that trying to run snapd without systemd isn't worth the headache. – Brian Z Feb 04 '23 at 20:26