Ubuntu
無法在 ubuntu 中使用 snap 安裝任何東西
所以,我試圖安裝 VS Code:
sudo snap install code --classic
但我收到以下錯誤:
error: cannot communicate with server: Post http://localhost/v2/snaps/code: dial unix /run/snapd.socket: connect: no such file or directory
我不知道該怎麼辦,我什至刪除並重新安裝了 snap,但錯誤仍然出現……
我做了:
sudo apt autoremove --purge snapd
接著:
sudo apt update && sudo apt upgrade sudo apt install snapd
它不起作用!
然後我嘗試了:
sudo service snapd start
輸出:
snapd: unrecognized service
如果我做:
snapd services
輸出:
snap 2.54.3+20.04.1ubuntu0.2 snapd unavailable series -
使用命令:
systemctl status snapd.service
我得到以下資訊,我的系統使用 sysvinit:
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
發生這種情況的原因是什麼?我正在使用 wsl2
如果您使用的是 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
在此處檢查 systemd 和 snap in WSL 的問題: