Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 无法保存根WSL2 VSCODE拥有的文件_Visual Studio Code_Wsl 2 - Fatal编程技术网

Visual studio code 无法保存根WSL2 VSCODE拥有的文件

Visual studio code 无法保存根WSL2 VSCODE拥有的文件,visual-studio-code,wsl-2,Visual Studio Code,Wsl 2,我有一个文件归root所有的项目,例如: > ls -la -rw-r--r-- 1 root root 36 May 6 20:57 README 该项目位于WSL2中,我使用的是VSCODE。 当我试图保存更改时,会收到以下错误消息: Failed to save 'README': Unable to write file 'vscode-remote://wsl+centos7/home/foteas/code/AppSrc/README' (NoPermissi

我有一个文件归root所有的项目,例如:

> ls -la
-rw-r--r--  1 root   root     36 May  6 20:57 README
该项目位于WSL2中,我使用的是VSCODE。 当我试图保存更改时,会收到以下错误消息:

Failed to save 'README': Unable to write file 'vscode-remote://wsl+centos7/home/foteas/code/AppSrc/README' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/foteas/code/AppSrc/README')
我不想更改文件或文件夹的所有权。
有没有办法通过VSCODE以root用户身份编辑文件?

这是一个已知问题。github问题中提出了一些解决方法

来自github上的Xunnamius:

我没有使用root ssh登录并以root身份运行代码,而是创建了
acl-enable for
acl-disable for
简单的脚本,这些脚本取自上述解决方案

例如,我为/etc/nginx运行了
acl enable,并记下以后为/etc/nginx运行
acl disable。请注意,
acl disable for
递归删除路径上的所有acl

在下面的命令中,您可能必须用文字用户名替换$USER

/usr/local/bin/acl为启用

#/usr/bin/env bash
#*在所选路径上递归启用读/写ACL
set-e
# ? 确保我们以root用户身份运行
如果[`id-u`-ne 0]];然后
echo“acl启用:请以root身份运行!”
出口1
fi
set+e
setfacl-R-mu:$USER:rwx“$@”
#setfacl-R-mu:$USER:rw“$@”#限制性更强一点
/usr/local/bin/acl禁用

#/usr/bin/env bash
#*递归清除所选路径上的所有ACL
set-e
# ? 确保我们以root用户身份运行
如果[`id-u`-ne 0]];然后
echo“acl禁用:请以root用户身份运行!”
出口1
fi
set+e
setfacl-Rb“$@”