When I change any file, the system will deny me access. What\'s going on? How do I properly set permissions on Mac?
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).
None of the above solutions solved this issue for me, here's what finally worked:
System Preferences > Security and Privacy > Privacy (tab) > (scroll down to) Files and Folders > Select Desktop Folder
If you want to fix permissions for the current user use sudo chown -R $(whoami) ~/.vscode/
.
$(whoami)
is a variable with the current user that's logged in~
is a shorthand for the home directory of the current userThis is the solution for me.
Open the Terminal and enter this command:
code --user-data-dir="./vscode-root"
This is for Ubuntu 16.04.
cd to the project directory and
run cd ..
to move back one folder
run sudo chmod -R 777 <project_dir_name>
it works for me vscode never asked me for password when saving my file again.
Here's the solution: You probably tried to save the file to "Macintosh Hd" which is the default place when you click on "Save as", so you can't just save a file to the computer inside itself, you have got to choose a directory, like you can save it to /Desktop or /users/your_username/... something like that. But saving to "Macintosh Hd" will always be unsuccessful.