When I change any file, the system will deny me access. What's going on? How do I properly set permissions on 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.
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.
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.
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>
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With