Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EACCES: permission denied in VS Code MAC

When I change any file, the system will deny me access. What's going on? How do I properly set permissions on Mac?

enter image description here

like image 340
劉明鑫 Avatar asked Aug 16 '16 16:08

劉明鑫


People also ask

How do you give permission to VS Code on a Mac?

Solution is to Give the folder 777 permission. In the terminal, the command to use to change file permission is “ chmod “. In short, “chmod 777” means making the file readable, writable and executable by everyone.

How do I unlink a usr bin code?

Open the command palette in VS Code using cmd + shift + p . Search "uninstall 'code'" and select the first option to uninstall. Once uninstalled, "install 'code'" for installing. That should fix it.

How do you enter codes on a Mac?

Drag Visual Studio Code. app to the Applications folder, making it available in the macOS Launchpad. Open VS Code from the Applications folder, by double clicking the icon. Add VS Code to your Dock by right-clicking on the icon, located in the Dock, to bring up the context menu and choosing Options, Keep in Dock.


2 Answers

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> 
like image 70
Nikhita Raghunath Avatar answered Oct 27 '22 11:10

Nikhita Raghunath


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).

like image 31
Arun Tom Avatar answered Oct 27 '22 11:10

Arun Tom