Eclipse, error: Couldn't write file "...." (permission denied) - eclipse

I have a maven project on eclipse linked with a git repository. When I try to save files, eclipse tells me that it couldn't save the file because the permission is denied. I noticed that it happened after I remove some class from my project.

This is because according to your system, you are not the owner of the particular directory. If you are using ubuntu here is what you can do:
Login as root user to do this, in terminal enter command
"sudo su"
provide your password.
Then navigate till the directory and enter command
"chown -v user_name -R folder_name/"
This worked for me hope will do for you.

Related

Set Permanent Flutter Path

The steps for modifying this variable permanently for all terminal sessions are machine-specific. Typically you add a line to a file that is executed whenever you open a new window. For example:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. The file path and filename might be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:
$ export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
Run source $HOME/.bash_profile to refresh the current window.
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
In mac, you should add it as follows in ".zshrc":
export PATH="$PATH:/Users/matteo/Documents/flutter/bin"
After you have updated the ".zshrc" file, run this command to ensure changes have been notified to OS
source ~/.zshrc
Reference: https://flutter.dev/docs/get-started/install/macos
A similar concept is for Linux system using bash files
I tried a lot of methods but this one permanent solution worked for me like a charm:
open Terminal in your Mac: type:
sudo nano /echo/paths
Add the code to the file:
/users/yourUserName/flutter/bin
Save the file using Control+X and Press Y and Enter
Hope this helps! :)

While opening VisualStudio it gives me following error

I have installed Visual Studio on my Linux(Ubuntu) machine but while I am opening it gives me error like...
By deleting the directory Code inside /home/[USERNAME]/.config, you'll be able to launch VScode again.
Step by step (replace USERNAME by your username):
$ cd /home/[USERNAME]/.config
$ sudo rm -rf Code
[enter your password if needed]
Then launch VSCode. It might probably take a moment till VSCode shows up, because the deleted folder will be recreated on launch.

bash: mongo: command not found

I installed mongodb on my system, but when I go to bin directory using Git and type mongo, this happens.
What shall I do?
The problem can solve if you add MongoDB path in the system variables:
Go to this path "Control Panel\System and Security\System" on the left you should see some options click on "Advanced system settings" after this click on "Environment Variables" at the System variables should be one option "Path" click that option and "Edit" it, add "New" variable on this system, in my case, is "C:\Program Files\MongoDB\Server\4.2\bin" and save this change.
if you're using git bash, use the following command
$ ./mongo
I've just had the same problem and did this to solve it. I hope it helps (late, but to be sure it is answered).
Open GitBash and type the following:
1) cd.. // to go to the root directory.
2) touch .bash_profile // creates a hidden file to set up the shortcut
3) notepad .bash_profile // this opens that hidden file with notepad. You can also do it with VIM if you want to master you command console skills...
4) paste these two command lines:
alias mongod="/c/Program\ Files/MongoDB/Server/4.0/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/Server/4.0/bin/mongo.exe"
!!! Check that your files are also in the same route as these. If not, modify what's needed. Mind the space between "\ Files" because this gave trouble too. You may need to change the version in case you don't have 4.0.
5) Save the file. Close Notepad.
6) At Gitbash again: CRTL + C, and close the console.
7) Open Gitbash again, go to the root, and type: mongo --version. If you see something like: MongoDB Shell version v4.0.10... you've been successful (see image). If not, check the route of the document you've put into the bash profile, and be sure to fully restart the bash console after.
Mongo install success
Hope that helps!
Use mongosh intead of mongo.
This solved my problem using docker
In later versions of this, you have to download mongo shell. Once you downloaded if zip extracts the files and moved folder to your program's folder. Renamed the folder mongosh. Copy the path and added to your environment variables path. it should look like this C:\Program Files\mongosh\bin. Next, if you haven't done so already. Create data folder in your root directory in my case windows c drive. Create a subfolder in the data folder called db. make sure this folder is in the root directory and not in the program's folder. Once this is done, close all the prompt windows and run again mongod and again run now not mongo but mongosh, and it will allow you to type in your code. I had to delete my previous created data folder that i created previous to installation of MongoDB hope this helps.

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?
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).
I managed to fix this on Mac while running this in Terminal
sudo chown -R $(whoami) /Users/$(whoami)/.vscode
hope this helps someone
Uninstall the code command from PATH in vscode and reinstall it.
Open the command pallete (command + shift + P), search "uninstall 'code'" and select the first option to uninstall.
Open the command pallete (command + shift + P), search "install 'code'" and click "Install 'code' command in PATCH
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
I found a fix. I simply uninstalled the code command from PATH in vscode and reinstalled. i.e open the command pallete, search "uninstall 'code' command in PATH" and select the first option to uninstall. Then do the same to install it back "install 'code'...". Do same for installing too. That should fix it
https://github.com/microsoft/vscode/issues/129884
props to lazy-poet
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.
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 user
Easy fix is: go to visual studio code and press cmd+shift+p and then the type 'uninstall code' select that option and reinstall it again with cmd+shift+p and type 'install code' and click.
Go to your project, double click on the app.js file and select 'Get info'. There will be an option of 'Sharing & Permission'. From there you can change access permissions for other users.
In my case, it turned out that the VSCode application was in the Downloads folder, and not in the Applications folder.
After I moved it to the Applications folder, I deleted the /usr/local/bin/code symlink. Then, I closed and re-opened VSCode, and hit Command+Shift+P and typed code which brought up Shell Command: Install 'code' command in PATH and successfully added code to the path!
I had a similar issue. I had error when I tried to create a new component. I just navigated to the path displayed in Finder. For me it was ProjectFolder/src/. So I did right click on "src" folder and selected "Get Info". In that change access to "Read&Write" for my user account. Thats it !!!
As you are trying to update a file, try to change access permission for that file (ie. app.component.css). If it didn't work try to change access for "app" folder.
Note: Changing the access of parent/super-parent folder won't work. So change the exact folder's access preferences.
In my case it was problems with mixed permissions within .git/objects directory. Some of them been my user, some - surprisingly - root.
This helped:
cd: .git/objects
sudo chown -R username:usergroup *
If mismatch with permissions occur not only within git objects but whole repo, chown command can be executed in upper directory.
This is the solution for me.
Open the Terminal and enter this command:
code --user-data-dir="./vscode-root"
This is for Ubuntu 16.04.
Go to your terminal and input the command:
sudo "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" ~/.bash_profile
It works for me.
However, according to the answers on the websites, it is not recommended to get super user permission when you launch the vs code. I am new to vs code as well so I don't know the right method to get permission.
Besides, on my mac, you will get only permission once when you type in the command and after you exit your vs code, you will not possess the permission if you open the vs code again. I am still working on it and try to fix.
But this answer should fix your problem.
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.
I Fix this on my M1 mac using this command.
sudo chown -R <userName> *
This command will allow ownership to the user for all files.
The problem is, that you are probably trying to access a project which is owned by a another user e.g. the user which is not currently logged in.
You need to login as that user to work on the project.

How do I edit .bash_profile with Visual Studio Code? It gives me a permission error

I want to edit .bash_profile with VS Code, but it presents a permission error when I try to save. Sublime typically prompts me with a Administrator login prompt.
Here's my current workflow...
From the Terminal, code ~/.bash_profile
Edit file in VS Code
Command+S
Permission Error: denied
Running vscode under sudo permissions is coming in the April release. Initially you will need to launch a new instance of VSCode and it will only be able to edit root-owned files, see https://github.com/Microsoft/vscode/issues/3068 for more details on the feature.
However, I recommend you change the ownership of ~/.bash_profile though as there's not reason you shouldn't be owning that file:
sudo chown YOUR_USER_NAME ~/.bash_profile