Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant permissions to VS Code to modify files in Windows Subsystem for Linux [closed]

I connected VS Code to WSL and when I try to save changes in my index.php file the following message shows up.

enter image description here

I tried to change the permissions on var/www/html using chmod but nothing changed.

So how to make VS code modify the file?

like image 670
Rain Avatar asked Nov 24 '19 18:11

Rain


People also ask

How do I give permission to VS Code?

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.

How do I change file permissions in WSL?

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.

How do I enable VS Code in WSL?

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.


1 Answers

Even I faced the same issue on my linux system, following command solved it:

  • Go to that directory from terminal.
  • Write 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.

like image 155
Amit Mondal Avatar answered Sep 17 '22 16:09

Amit Mondal