Why can't I create a new file in my working directory?

Issue

I am using PHPStorm 10.0.3 on Windows 7, and I have had no problems working in my project so far. But for some reason, I come into work this morning and suddenly I’m not able to create a new file in any of my directories in my project? This is the error that’s occurring:

Unable to create file example.php in selected directory

The error appears 2 more times after I click OK.

I am still able to go into Windows Explorer and create the file manually, so that will tide me over until this problem is resolved.

Thank you all in advance for helping me with such a silly problem.

UPDATE:

It seems PHPStorm thinks the project is “read-only” because when I try and create a new file in the root of the project, I get the error “Cannot modify a read-only directory” followed by the path. I tried using the attrib windows command to remove all read-only attributes but it still hasn’t worked.

Solution

I’m not sure what fixed the problem, but I tried two things and I thought both of them didn’t work. I’ll explain exactly what I did for reference to fix this problem.

Firstly, I should announce that I (used to) use Google Drive for all my projects for automated backups. I think that may have messed with the permissions, so I took all my projects out of Google Drive and stopped the process. Didn’t fix.

So, I did a combination of the following:

  1. Right-click on the folder, go Properties, and uncheck the Read-only box and make sure it affected subfolders and files too.
  2. Change the permissions on the entire folder so that I was owner, and that “Everyone” had full access to it.
  3. After both didn’t seem to work, I tried making a file in the root directory and noticed something about it being read-only. I found out about Windows’ “attrib” command, so I performed “attrib -r -s /S /D project-folder-name” whilst in the parent folder of my directory. This also didn’t seem to work.

It was at this point I wanted to know if my other projects in the same directory were affected. I closed the problem project, opened another project and tried making a file anywhere. It worked. I tried this for them all. They all worked. So, I went back to the problem directory… and it worked.

I think after making all those changes, I hadn’t actually restarted PHPStorm or changed project. I recommend, when trying each of my steps above, restart PHPStorm completely or at least change project to make sure the problem project is closed so you can properly test if the step worked.

I hope this helps someone in the future.

Answered By – Psymøn

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published