EACCES: permission denied in VS Code MAC

Solution 1:

It is generally not a good idea to run VS Code as sudo. Instead change the permission for the directory.

You can change the ownership of the directory so that you can open it without needing root privileges.

$ sudo chown -R <user-name> <directory-name>

Solution 2:

First, take note of the current permissions of all files and folders by issuing the command:

ls -lR <project_dir_name> > old_permissions.txt

which will save the output of the command ls -l <project_dir_name> to the file old_permissions.txt in the current directory.

If you have no idea of how permissions work and what the results of the previous command represent, please, have a look at https://ss64.com/bash/syntax-permissions.html and https://ss64.com/bash/chmod.html.

At this point, to modify any of the files under <project_dir_name>, you can give full permission to all subfolders and files recursively by issuing the command:

sudo chmod -R 777 <project_dir_name>

Note that you're responsible for the changes your perform!

After having saved the updates, you can reset the previous permission settings of the folders by looking at the old permissions saved in the file old_permissions.txt. You should set the permissions manually (unless you create e.g. a script to do it automatically using the info saved in old_permissions.txt).

Note: it's probably a better idea to only modify the permissions of the specific files that you want to modify (and not of the whole folder).

Solution 3:

I managed to fix this on Mac while running this in Terminal

sudo chown -R $(whoami) /Users/$(whoami)/.vscode

hope this helps someone