Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VScode unable to save files inside my WSL2 home folder

I'm trying to make WSL2 work for my web projects development and this is driving me crazy!

Basically, i have two options. 1. Save my project files into c drive and access those with WSL (which makes the responses extremelly slow) 2. save my project files into /home/ which makes the project run super smooth, but i'm unable to edit those files with VSCode.

The error that is what follows:

Failed to save 'DefaultSeeder.php': Unable to write file 'vscode-remote://wsl+ubuntu-20.04/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php')
like image 923
Lucas Pacheco Avatar asked May 23 '20 14:05

Lucas Pacheco


People also ask

How do I save in WSL?

If you're working in a Windows command line (PowerShell, Command Prompt), store your files in the Windows file system. For example, when storing your WSL project files: Use the Linux file system root directory: \\wsl$\Ubuntu\home\<user name>\Project.


3 Answers

Here is another command to provide your user with sufficient permissions to write to files:

sudo chown -R myuser /path/to/folder

From https://github.com/microsoft/vscode-remote-release/issues/1008

like image 122
ansona Avatar answered Oct 13 '22 05:10

ansona


Well, turns out I was being stupid and posted a stupid question.

After many hours trying to make this damn thing work, I was able to do so, by setting the ownership of the folder to my user.

Here is the shell snippet to change the ownership to the current logged in user:

$ sudo find /~~folder-path~~/ -type d -user root -exec sudo chown -R $USER: {} +~
like image 17
Lucas Pacheco Avatar answered Oct 13 '22 05:10

Lucas Pacheco


This solved it for me

sudo find /home/ -type d -user root -exec sudo chown -R $USER: {}  \;
like image 11
ali Saen Avatar answered Oct 13 '22 04:10

ali Saen