无法保存根 WSL2 拥有的文件 VSCODE
Unable to save files owned by root WSL2 VSCODE
我有一个文件属于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 问题 here.
中提出了一些解决方法
来自 github 上的 Xunnamius:
Rather than enter a security nightmare with root ssh logins and running code as root, I created acl-enable-for
and acl-disable-for
simple little scripts taken from the solutions above.
For example, I run acl-enable-for /etc/nginx
and make a note to run acl-disable-for /etc/nginx
later. Note that acl-disable-for
deletes all ACLs on a path recursively.
You may have to replace $USER with your literal username in the command below
/usr/local/bin/acl-enable-for
:
#!/usr/bin/env bash
# * Enables a read/write ACL on the chosen path(s) recursively
set -e
# ? Ensure we're running as root
if [[ `id -u` -ne 0 ]]; then
echo 'acl-enable-for: please run as root!'
exit 1
fi
set +e
setfacl -R -m u:$USER:rwx "$@"
# setfacl -R -m u:$USER:rw "$@" # a bit more restrictive
/usr/local/bin/acl-disable-for
:
#!/usr/bin/env bash
# * Clears all ACLs on a chosen path recursively
set -e
# ? Ensure we're running as root
if [[ `id -u` -ne 0 ]]; then
echo 'acl-disable-for: please run as root!'
exit 1
fi
set +e
setfacl -Rb "$@"
我有一个文件属于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 问题 here.
中提出了一些解决方法来自 github 上的 Xunnamius:
Rather than enter a security nightmare with root ssh logins and running code as root, I created
acl-enable-for
andacl-disable-for
simple little scripts taken from the solutions above.For example, I run
acl-enable-for /etc/nginx
and make a note to runacl-disable-for /etc/nginx
later. Note thatacl-disable-for
deletes all ACLs on a path recursively.You may have to replace $USER with your literal username in the command below
/usr/local/bin/acl-enable-for
:#!/usr/bin/env bash # * Enables a read/write ACL on the chosen path(s) recursively set -e # ? Ensure we're running as root if [[ `id -u` -ne 0 ]]; then echo 'acl-enable-for: please run as root!' exit 1 fi set +e setfacl -R -m u:$USER:rwx "$@" # setfacl -R -m u:$USER:rw "$@" # a bit more restrictive
/usr/local/bin/acl-disable-for
:#!/usr/bin/env bash # * Clears all ACLs on a chosen path recursively set -e # ? Ensure we're running as root if [[ `id -u` -ne 0 ]]; then echo 'acl-disable-for: please run as root!' exit 1 fi set +e setfacl -Rb "$@"