Reputation: 5452
How do I resolve the vs code Insufficient permission issue when saving a file
I've given appropriate permissions to code directory: chown -R me:staff my-app/
But when I open vscode and try to save a file it says "Insufficient permissions, Retry as admin"
If I launch vscode with sudo from cmd line sudo code . then I dont get that error but then the autocompletion extensions dont seem to work
Upvotes: 107
Views: 247469
Reputation:
Problem Problem to save App.js file in React App.
VSCODE Error : Failed to save 'App.js': insufficient permissions. Select 'Retry as Sudo' to retry as superuser.
Solution For Linux
sudo chown -R UserName AppName
Example
sudo chown -R yogi my-app
Upvotes: 3
Reputation: 452
simply try exiting vscode (by discarding changes if 'save as sudo' doesn't work either) and relaunch vscode
Upvotes: -2
Reputation: 1
Easy solution is to simply switch to bash in terminal. This will allow you to modify files as usual. When you start your project, use sudo.
For example: sudo nom start
Upvotes: 0
Reputation: 549
Add the user logging in via the RemoteSSH to the group that owns the files/folders and set the folder permissions to g+w.
Remember to restart/reboot the RemoteSSH server/machine to apply the changes.
Upvotes: 0
Reputation: 716
sudo chmod -R a+rwx folder_of_work
This will work. Will make available all permissions: write, read and execute from all to the folder of work. The -R is for making all these permissions also on the files and folders inside the folder_of_work.
Upvotes: 7
Reputation: 339
I encountered this error after executing sudo git pull on ubuntu, The issue was solved by Changing the file/directory persons for the owner, group and others for all the files and the folders for the project by running sudo chmod -R 770 projectFolder don't run sudo chmod -R 777 projectFolder for security reasons
Upvotes: 2
Reputation: 4794
Insufficient permissions. Select 'Retry as Sudo' to retry as superuser.
In Ubuntu 20.04 try these commands to give the right permission to your files and folders:
cd /PATH/TO/YOUR/FOLDER
sudo chown -R $USER:www-data .
sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 775 {} \;
Then try to save your files again.
Upvotes: 0
Reputation: 4262
On Windows10, I solved adding "modify" permissions (to "authenticated users") to the project folder.
Upvotes: 1
Reputation: 1143
The two simplified steps i found useful are:
cd /var/www/target-directory
chown $(whoami) -R .
code .
to open current directory in vscode and everything should be working.
$(whoami)
- pipes the result of the current user for home tochown
command. Its concise and direct.
-R command instructschown
to recursively change sub directories in this directory
Upvotes: 7
Reputation: 313
On windows 10 my Antivirus was the reason for this error to happen.
I had to add the folder where the file I wanted to save was to the excluded folder of my Ransomware protection.
Upvotes: 0
Reputation: 2872
This problem can be solved by changing the permissions of the project user to yourself.
However, if you change the permissions of a file, when you are developing a team, you can end up pushing even the permissions of the file to git.
If this happens, you may be warned by the team.
So, it would be better if you change the permissions of your local project folder and at the same time ignore the push of file permission changes to git.
This way, files with changed permissions won't be published online.
$ sudo chown -R userName /Users/userName/projectName
$ cd /Users/userName/projectName
$ git config core.filemode false
$ git config -l | grep filemode
Verify that core.filemode = false
git config core.filemode is set to true by default, and if it's not set to false, it will automatically convert to 644 if the permissions are set to 755
【Vscode】How to solve the problem when a file cannot be updated due to lack of permissions in vscode
Upvotes: 0
Reputation: 271
It looks like you somehow changed file ownerships in your home directory.
One way to correct this without endangering your system is
sudo chown -c -R $USER:$USER $HOME
Explanation:
chown: change the ownership of files/directories
-c: report all changes
-R: do this recursively (for all files/directories beneath the given one)
$USER:$USER: change the owner and the group that owns the the entry to the user that issues the command (sudo preserves the values)
$HOME: do this with your home directory
You can test those environment variables with the following commands
echo $USER
sudo echo $USER
echo $HOME
sudo echo $HOME
Upvotes: 0
Reputation: 29
Give permission to your project folder like below
sudo chown -R $USER:$USER your_project_folder_name
Upvotes: 3
Reputation: 2191
Try this code:
sudo chown -R username directory_name
where,
username
is the username of the user of the laptop you want to give access fordirectory_name
is the name of the directory whose permissions you want to changeUpvotes: 211
Reputation: 887
Should I give you a fish? Nope.. that's is not right at all! I should teach you how to fish and it'll save you for a lifetime.
Dear anyone, the issue is all about access permission to that directory or even file sometimes. So you need to use chmod
command to change access permission and we normally use access codes which work as a combination of three octal digits (0-7).
The three
chmod
codes set permissions for these three groups in this order:1. Owner (you) 2. Group (a group of other users that you set up) 3. World (anyone else browsing around on the file system)
Each digit of this code sets permissions for one of these groups as follows. Read is 4. Write is 2. Execute is 1.
The sums of these numbers give combinations of these permissions:
0 = no permissions whatsoever; this person cannot read, write, or execute the file 1 = execute only 2 = write only 3 = write and execute (1+2) 4 = read only 5 = read and execute (4+1) 6 = read and write (4+2) 7 = read and write and execute (4+2+1)
Read more from this article
Hence, in your case you could try running sudo chmod 777 folder-name
which I'm sure it's gonna work! But... It's not safe for use!!! keep it away from the reach of yourself! IT'S A RISK!..
I would suggest to try 755 to make it work. Or something different since you now understand what you're doing! (I mean to fish!)
Upvotes: 18
Reputation: 597
For me I had same problem am working on windows 10 OS
just from Project folder -> Properites -> UnCheck Read-Only in attributes
Upvotes: 0
Reputation: 160
You can just change the ownership of your project folder.
sudo chown -c -R $USER:$USER (project folder)
Explanation:
You can test those environment variables with the following commands
echo $USER
sudo echo $USER
Upvotes: 3
Reputation: 27
This is because you are not running VS Code as administrator. So VS Code does not have permission to save files.
You should always run VS Code as administrator. To do this, go to the folder where you installed it. By default, VS Code is installed under C:\users\{username}\AppData\Local\Programs\Microsoft VS Code
.
Find the file "Code.exe" and open properties, go to the tab "Compatibility" and check the field "Run this program as administrator".
This method worked out well for me.
Upvotes: -4
Reputation: 1803
Try with the below command(For linux/mac)
sudo chown -R abhinav-kumar my-app
Let’s break this down.
Upvotes: 27
Reputation: 3532
Please, don't use 777
for permissions, it's a security risk.
In your project folder run (replacing <user>
with your username):
chown <user>:<user> -R .
If any file is owned by root
, then it'll require sudo
.
755
find . -type d -exec chmod 755 {} +
644
Let's start changing only the source files. As my project is a Python project, let's apply the change initially only for .py
source files (change the extension to your source files):
find -name "*.py" -exec chmod 644 {} +
Check if it works.
If this is not enough, you can additionally change permission of all project files to 644
, but maybe this will change the permission for images and some executables.
So, being warned that you can change images and binaries permissions:
find . -type f -exec chmod 644 {} +
Upvotes: 10
Reputation: 2704
You should add your User or the User who is currently logged in to the folder and grant Read and Write access.
Upvotes: 8
Reputation: 3032
Change the permission level of your project directory, for example:
sudo chmod -R 777 testproject
Upvotes: 121