受够了双系统来回切换,尝试了一下wsl配置linux环境(我的习惯在linux上敲代码),因为需求图形化,又弄了xserver。没有装linux图形界面。php
WSL
安装按着官方的文档来
linux
注意wsl2须要Insider Previe版本,我的在更新版本的时候由于杀毒软件的缘由在重启的时候会绿屏报“PAGE_FAULT_IN_NONPAGED_AREA”,错误代码0xc1900101,引觉得戒。windows
linux发行版选择了Ubuntu 18.04LTS,MIcrosoft Store还有其余发行版可供选择。这里没有的发行版能够自行折腾(如Arch )。bash
能够在Microsoft Store中安装Windows Terminal,能够快速打开wsl的终端。ide
Xserver
我的使用的是VcXsrv。测试
在WSL中配置环境变量DISPLAY,在~/.bashrc中加入相关配置。ui
WSL1为:spa
export DISPLAY=localhost:0
WSL2为:.net
export DISPLAY=`cat /etc/resolv.conf | grep nameserver | awk '{print $2}'`:0
(这里参考https://zhuanlan.zhihu.com/p/51270874)插件
随后打开Xlaunch,注意要勾选Disable access control,不然会报,其余为默认选项。
Authorization required, but no authorization protocol specified Error: Can't open display
(这里参考https://codeyarns.com/2019/05/11/vcxsrv-x-server-for-windows/)
能够用xeyes测试一下。
VSCode
在win上安装vscode,打上Remote-WSL插件,就能经过vscode直接使用wsl的环境了,至关方便。
vscode能够管理wsl中的插件,这些插件会和本地的win区分开来。