Snapd 服务未运行/在 Ubuntu 16.04 上安装 snap 包时出现问题

Snapd 服务未运行/在 Ubuntu 16.04 上安装 snap 包时出现问题

使用 snap 安装 Heroku 时遇到了一些问题。以前从未使用过,通常使用 pip。以下是发生的情况:

(legal_subs_3.6) (xenial)amessios@localhost:~$ sudo snap install heroku --classic
error: cannot communicate with server: Post http://localhost/v2/snaps/heroku: dial unix /run/snapd.socket: connect: no such file or directory


(legal_subs_3.6) (xenial)amessios@localhost:~$ snap find heroku
error: cannot list snaps: cannot communicate with server: Get http://localhost/v2/find?q=heroku&scope=wide: dial unix /run/snapd.socket: connect: no such file or directory

我已经尝试过迄今为止在网上可以找到的修复/检查,但无济于事:

(legal_subs_3.6) (xenial)amessios@localhost:~$ snap --version
snap    2.39.2ubuntu0.2
snapd   unavailable
series  -


(legal_subs_3.6) (xenial)amessios@localhost:~$ sudo service snapd start
snapd: unrecognized service


(legal_subs_3.6) (xenial)amessios@localhost:~$ sudo service snap start
snap: unrecognized service


(legal_subs_3.6) (xenial)amessios@localhost:~$ systemctl status snapd
Failed to get properties: Launch helper exited with unknown return code 1


(legal_subs_3.6) (xenial)amessios@localhost:~/code/test_projects/lawyer_bios/lawyer_bios$ systemctl start snapd.service
Failed to add /run/systemd/ask-password to directory watch: No such file or directory
Failed to start snapd.service: Launch helper exited with unknown return code 1
See system logs and 'systemctl status snapd.service' for details.


(legal_subs_3.6) (xenial)amessios@localhost:~/code/test_projects/lawyer_bios/lawyer_bios$ systemctl status snapd.service
    Failed to get properties: Launch helper exited with unknown return code 1

有任何想法吗?

答案1

只需重新启动服务即可。

$ systemctl start snapd.service

答案2

如果你使用的是 Windows WSL,请运行以下命令:

git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
sudo bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished
cmd.exe /C setx WSLENV BASH_ENV/u
cmd.exe /C setx BASH_ENV /etc/bash.bashrc

在这里检查 WSL 中的 systemd 和 snap 的问题: https://github.com/microsoft/WSL/issues/2374

https://github.com/damionGans/ubuntu-wsl2-systemd-script

答案3

如果你遇到这个问题那么打开终端然后输入

sudo service snapd start

答案4

如果其他服务没有帮助,请尝试重新启动 snapd.apparmor

sudo systemctl restart snapd.apparmor

相关内容