Loading Blog Search...

Wednesday, October 28, 2020

Run snap in WSL2

To use snap in WSL2, we need systemd enabled, following instruction at https://github.com/diddledan/ubuntu-wsl2-systemd-script/. However after enabling systemd using the script, visual studio code can't open terminal anymore. There will be a fix. Before you receive the fix, there is a workaround, to change the last several lines of to:
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a /bin/login -p -f "$SUDO_USER"
My MobaXterm also can't open WSL session. Not sure whether it is caused by above scripts. A workaround is to change default shell to cmd/powershell and run bash from there. To run GUI apps from WSL, we could use vcxsrv/x410 or MobaXterm. vcxsrv is more bugful though. Due to WSL is using different network interfaces, we can set DISPLAY by adding the line to ~/.bashrc: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0