I connected VS Code to WSL and when I try to save changes in my index.php
file the following message shows up.
I tried to change the permissions on var/www/html
using chmod
but nothing changed.
So how to make VS code modify the file?
The two simplified steps i found useful are: cd to that directory cd /var/www/target-directory. change ownership to home user where vscode has all write-read permissions chown $(whoami) -R . Then do code . to open current directory in vscode and everything should be working.
You can configure your file permissions inside of your Windows drives using the mount options in wsl. conf. The mount options allow you to set umask , dmask and fmask permissions masks. The umask is applied to all files, the dmask is applied just to directories and the fmask is applied just to files.
From VS Code Start VS Code. Press F1, select Remote-WSL: New Window for the default distro or Remote-WSL: New Window using Distro for a specific distro. Use the File menu to open your folder.
Even I faced the same issue on my linux system, following command solved it:
sudo chown -R <username>:<group> <directory_name>
. This command will change ownership (both user and group) of all files and directories inside of directory and directory itself.To know the username write whoami
in terminal.
To know the group write groups
in terminal (The first name in the list is your group name) for me both username and groupname was same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With