vsc连接wsl安装vsc时遇到权限问题的解决方案

当点击左下角的连接

遇到下面的权限提示时

mkdir: cannot create directory ‘/home/xxx(用户名)/.vscode-server’: Permission denied

可以新建文件 /etc/wsl.conf,并拷贝如下内容

# Automatically mount Windows drive when the distribution is launched
[automount]

# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true


# DrvFs-specific options can be specified.  
options = "metadata,umask=22,fmask=11"

# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
mountFsTab = true

参考文章:

wsl2使用vscode无法写入文件permission denied解决方法_阿正的梦工坊的博客-CSDN博客

https://stackoverflow.com/questions/61973385/vscode-unable-to-save-files-inside-my-wsl2-home-folder

https://docs.microsoft.com/en-us/windows/wsl/file-permissions