Dani F
Dani F

Reputation: 701

VS Code: NoPermissions (FileSystemError): Error: EACCES: permission denied

I'm trying to save a file called app.js on a folder called js.

Vs Code pop up this:

Failed to save 'app.js': Unable to write file 'vscode-remote://wsl+ubuntu-18.04/js/app.js' (NoPermissions (FileSystemError): Error: EACCES: permission denied, mkdir '/js')

I tried:

sudo chown -R user /mnt/c/Users/myUser/Documents/myFolder/proyectFolder

but I still can't save this file.

Upvotes: 60

Views: 160980

Answers (11)

Justin
Justin

Reputation: 213

If you created some file using Docker with root account like docker exec .... You won't be able to edit that outside Docker, because of permission issue.

$ ls -l
-rwxr-xr-x 1 1000 1000  668 Oct 22 04:17 old_file
drwxr-xr-x 3 root root 4096 Oct 22 04:53 new_file_created_inside_docker

In this case, you can see the new_file is owned by root.

To fix that

chown -R 1000:1000 new_file_created_inside_docker/

Upvotes: 0

Emanuel
Emanuel

Reputation: 2029

Try this, fixed it for me

sudo chown -R username path 

Example:

sudo chown -R emanuel /home/emanuel/test/

Upvotes: 202

yts61
yts61

Reputation: 1599

Just go to Settings, then search for UNC. Uncheck "Security: Restrict UNCAccess" This works for me. enter image description here

Upvotes: 0

It is a Linux user permissions problem. you should use the command:

    sudo chown -R $USER:$USER.

Upvotes: 0

Niranjanadas M
Niranjanadas M

Reputation: 353

In the SSH terminal:

Recommended:

sudo chmod -R 777 folder_name_where_your_file_exists 

or

sudo chmod -R 755 folder_name_where_your_file_exists 

Upvotes: 18

Rifando Panggabean
Rifando Panggabean

Reputation: 309

This works for me:

sudo chown -R $USER:$USER /home/

Upvotes: 20

Nitin Jadhav
Nitin Jadhav

Reputation: 527

Install the extension Save as Root in Remote SSH in VS code.

  • While saving press Ctrl + Shift + P.
  • This open the command palette.
  • Search Save as Root

Upvotes: 3

Burak Ozcelik
Burak Ozcelik

Reputation: 131

The below is for individual file:

sudo chown yourUserNAme filename

For an entire directory it will be (when you write ls to terminal, you should see your directory to execute this command):

sudo chown yourUserNAme dirName

For recursive (i.e files and folders inside a folder):

sudo chown -R yourUserNAme dirName

Note: yourUserNAme is, if you do pwd under any Documents, you will see the path: /home/jhon/Documents. Here user is jhon.

Upvotes: 1

zsega
zsega

Reputation: 171

TLDR;

If you're using a docker container, avoid making files from within the container because the owner and group permissions may cause problems with your editor (in my case VS Code)


I was running docker container for a Django project from Windows Terminal and using VS Code to edit my code.

It is a Linux file (since everything in Linux is a file) permission problem that arises because the files don't have proper user and/or group permissions. So VS Code tries to tell us that.

The problem I found only happened when I created files from within my docker container.

  • I would run docker exec ... bash
  • make new files using touch /path/to/file from the container bash
  • then try to edit those files on VS Code (say urls.py) only to get the scary permissions error preventing the file from saving.

I suspect that making files from within the container embellishes those files with different owner and group settings than your system would default to if you just ran the commands locally (not in the container).

Changing the file permissions with chown -hR and chgrp -hR would do the trick but to avoid the error altogether I stopped making files from within the container.

Upvotes: 6

CedricYao
CedricYao

Reputation: 189

Try activating polling:

This worked for me during I tried using wsl.

enter image description here

Upvotes: 2

Related Questions