我正在尝试使用安装 heroku cli
sudo snap install heroku --classic
命令行说
error: cannot communicate with server: Post http://localhost/v2/apps: dial unix /run/snapd.socket: connect: no such file or directory
我试过systemctl status snapd.service
这是结果:
snapd.service
Loaded: masked (/dev/null; bad)
Active: inactive (dead)
我试过systemctl restart snapd.service
它说:
Failed to restart snapd.service: Unit snapd.service is masked.
任何帮助解决上述问题的人都将不胜感激。谢谢。
答案1
揭开snapd.service
:
sudo systemctl unmask snapd.service
启用它:
sudo systemctl enable snapd.service
启动它:
sudo systemctl start snapd.service
然后尝试安装您想要的应用程序。
答案2
对于 WSL 特定的答案,我在 WSL Ubuntu 24.04 预发行版上遇到了这个问题,当时 systemd 被禁用,给了我类似的错误
$ 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
我通过添加来修复它
[boot]
systemd=true
至/etc/wsl.conf
,然后重新启动 WSL :)(以管理员身份启动 PowerShell 并运行wsl --shutdown
),现在 Snap 运行良好。
在对 Ravexina 的回答的评论中,我认为这可以解决 Andy、Jortega 和 Brian Z. 的问题。但我无法 ping 他们。