PowerShell-Snap icon indicating copy to clipboard operation
PowerShell-Snap copied to clipboard

Not working on Ubuntu 20.04 on WSL2

Open tig opened this issue 4 years ago • 1 comments

sudo snap install powershell --classic
sudo snap install powershell-preview --classic

I just installed Ubuntu on WSL2 via the Windows Store and neither of these commands are working:

tig@valdez:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
tig@valdez:~$ do-release-upgrade
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release
set Prompt=normal in /etc/update-manager/release-upgrades.
tig@valdez:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
tig@valdez:~$ sudo snap install powershell --classic
error: cannot communicate with server: Post http://localhost/v2/snaps/powershell: dial unix /run/snapd.socket: connect: no such file or directory
tig@valdez:~$ sudo snap install powershell-preview --classic
error: cannot communicate with server: Post http://localhost/v2/snaps/powershell-preview: dial unix /run/snapd.socket: connect: no such file or directory

What am I missing?

tig avatar Oct 15 '20 19:10 tig

Hi, @tig

The out-of-the-box Ubuntu installation is unable to run snapd and therefore you are unable to issue snap commands to install or run Snap Packages. This is because WSL and WSL2 cannot run the snapd requirement of systemd due to Microsoft's init process being "in the way" (systemd requires to be executed as ProcessID 1 but the Microsoft init has that process ID). For WSL (not WSL2) that is the end of the story. However, on WSL2 you can hack it to run systemd inside a container, and therefore be able to use Snap Packages. I maintain one of several similar projects at https://github.com/diddledani/one-script-wsl2-systemd (I've also linked to other projects that I know about in the readme there).

Due to these issues being WSL itself as the problem I recommend that this ticket be closed without a fix.

lucyllewy avatar Sep 10 '21 17:09 lucyllewy