Duskendale
Duskendale

Reputation: 164

VSCode can't write to files in Bash for Windows

I've been using Bash for Windows recently (its the Ubuntu "app") and I can open VSCode from the bash command line but when I try to save any modifications I've made to the file, it just says permission denied.

I've tried creating the files directly from VS Code's terminal but in that case it doesn't print out an error message but it also doesn't save anything.

Upvotes: 1

Views: 4067

Answers (1)

Pedro Lopes
Pedro Lopes

Reputation: 26

That happens because you dont have permissions to write in the system32 folder. If you run the Ubuntu application as an administrator, you'll get the permissions to write. However, you won't be really in that file, because of the way that the virtualization of files and errors might happear doing so, and I do not recommend to run the console in a privilege mode (for seccurity issues). Fortunately, in version 1903 of Windows 10, this will change, and you'll be able to navigate the WSL folders via Windows Explorer, and for sure that issue will disappear.

Edit: the best practice, you do the work in a folder in the Windows File System, and cd to there in the WSL console. VSCode has this integrated very well, if you have an open file in VSCode you can just do New Terminal and choose a WSL terminal. The terminal will already be in the folder where you file is.

Upvotes: 1

Related Questions