Reputation: 227
I recently installed Ubuntu 20.04 WSL2 on my Windows 10 machine. All I've done so far is update
and upgrade
, and installed a few packages so I can use the GUI version of Ubuntu applications. I followed this tutorial for the GUI if you want to know what I did, skipping the part about making a file /etc/sudoers.d/dbus
I tried running sudo snap install --classic code
but I get error: cannot communicate with server: Post http://localhost/v2/snaps/code: dial unix /run/snapd.socket: connect: no such file or directory
I found that I should check if snapd
is running, when I run systemctl status snapd
I get System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
I just tried an alternative method of installing VSCode with sudo apt install code
but I get this message
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package code
I thought maybe it needed be shutdown and retsarted, I did that to my whole laptop but to no avail. I also tried to restart/shutdown inside the terminal after the fact with sudo shutdown -r
and I get the same error -
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Any thoughts on what could be going wrong?
Upvotes: 1
Views: 965
Reputation: 20733
When using WSL, you really want to install the Windows version of VSCode. It provides tight integration with WSL through the WSL/Windows interop features. When installed under Windows, you can still access it from WSL with a simple:
code .
This is provided by a shell script in the VSCode/bin
directory that WSL will run, which in turn bootstraps the Windows executable. The first time you run it, it will install a lightweight server inside WSL for some additional interop.
Once installed, add in the Remote Development extension pack. This includes the Remote - WSL, Remote - Containers, and Remote - SSH extensions. You can open files directly from the WSL filesystem, start a WSL terminal from within VSCode, etc.
As for the Linux version of VSCode, the problems you are running into are because WSL does not support Systemd (neither version 1 nor version2) nor Snap without extensive additional effort (that honestly, I've never found it worthwhile to do).
Upvotes: 2