The IDE cannot create the directory. Possible reason: parent directory is read-only or the user lacks necessary permissions

Viewed 14113

When I trying to install Android Studio on my PC so the error occurs it says:

The IDE cannot create the directory. Possible reason: parent directory is read-only or the user lacks necessary permissions.

If you have modified the idea.config.path property, please make sure it is correct, otherwise, please re-install the IDE.


Location: C:\Users\Acer/.AndroidStudio4.0/config java.nio.file.AccessDeniedException: C:\Users\Acer.AndroidStudio4.0

enter image description here

13 Answers

I had the same problem but on MacOS, so I thought it might be useful to share the solution for someone who is using Mac like me. Navigate to: /Applications/Android Studio.app/Contents/MacOS, i.e. on terminal execute the following: cd /Applications/Android\ Studio.app/Contents/MacOS then execute: sudo ./studio. This would be enough for the IDE to be executed once so it can create config folder and file. Then everything will be ok.

I just ran into this bug on a MacBook and to fix it I ran: sudo chmod 777 ~/Library/Application\ Support/Google in the terminal.

The above answer helped me solve it on my machine, but I had to create a directory for Android studio in the designated folder and give that proper permission. Steps

  1. Navigate to username/Library/Google
  2. if there is an AndroidStudio{version} folder, jump to step 3, otherwise create a new folder called AndroidStudio{version} where you swap out the version number. You can find the number in the error message spelled out at the bottom.
  3. right click that folder, and get info.
  4. go to sharing & permissions and give staff+everyone: read-write permission.

TLDR:

  • Add read/write permissions to the folder that the IDE mentions.
  • If it does not exist create it
  • Ensure that the folder has READ/Write permissions for your local user.
  • After all this the app would still crash when opening new tabs. So i had to run defaults write com.google.android.studio AppleWindowTabbingMode manual as found in this answer. https://stackoverflow.com/a/64907362/1461176

I ran into this issue recently on Mac OS Sierra. I wasn't comfortable running the app in sudo or setting generic directories like Library/Catches as globally read/write by all users.

cannot create directory The full message was:

The IDE cannot create the directory.
Possible reason: parent directory is read-only or the user lacks necessary permissions.

If you have modified the 'idea.config.path' property, please make sure it is correct,
otherwise, please re-install the IDE.

-----
Location: /Users/username/Library/Application Support/Google/AndroidStudio4.1
java.nio.file.AccessDeniedException: /Users/username/Library/Application Support/Google/AndroidStudio4.1

I have another mac that has Android Studio already setup. So I investigated how it was setup.

The location of the folder was slightly different: /Users/username/Library/Application\ Support/AndroidStudio4.1/.

Notice it's not in the shared Google folder. This shouldn't matter but I believe can be configured with idea.config.path.

The difference in path is probably related to the version of Android Studio that was initially installed.

After opening the permissions on that folder in the working computer, i noticed it had Read/Write for my local user.

Yet the offending computer did not.

Share Permissions did not include my user

I can confirm that editing the permissions fixes this issue and you can reproduce if you remove it.

  • cd to the path output in the error in my case that was: `cd /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • If it does not exist create it sudo mkdir /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • open the parent folder open /Users/username/Library/Application Support/Google/
  • Right click -> Get Info on the /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • Select the lock in the bottom right
  • Select the plus + button on the bottom right.
  • Enter your login password
  • Select your username
  • Change Privilege field for your username to Read/Write
  • Press the lock
  • Close the window
  • Open android Studio

Similar Error If you receive an error related to creating temp files in the the folder the folder is present but it's permissions are still not correct.

cannot create tmp file

Possible reason: the directory is read-only or the user lacks necessary permissions.

If you have modified the 'idea.config.path' property, please make sure it is correct,
otherwise, please re-install the IDE.

-----
Location: /Users/username/Library/Application Support/Google/AndroidStudio4.1
java.nio.file.AccessDeniedException: /Users/username/Library/Application Support/Google/AndroidStudio4.1/ij1547365868.tmp

I had a similar problem on Ubuntu. At first, I tried running ./studio.sh as root. However, I faced other issues down the line. So I cleaned the .cache directory that was created by the root user, also deleted the Google/AndroidStudio* and "Android Open Source Project" under .config. Then I was able to run ./studio.sh without any root permissions.

my problem was solved by visiting the C:\Users\Myusername\AppData\Local\JetBrains and giving it the proper permission.

This error is caused by permission problem at the spelled out folder at the bottom of the error message.

for Mac, go to YourUserName/Library/Catches. Right click on the catches folder, go to Get Info, and change the "Sharing & Permissions" settings under "everyone" and "staff" to "Read & Write".

I had the same issue trying to build a project using capacitor. I was able to fix it simply by adding sudo before the command. So instead of npx cap open android I did sudo npx cap open android and it worked.

Also this issue can occur if there is no enough space on your PC. So double check it just to be sure. Generally answer provided by T-D helps to get more descriptive message in that case.

On my mac, same error, I deleted this folder:

/Users/xxxxxxxxxxx/Library/Caches/Google

Which was a symlink to /Volumes/RamDisk/Library/Caches/Google

It works perfectly.

In MacOS the folders inside /Users/<user>/Library/Application Support/ should all be owned by <user>:staff.

In my case /Users/<user>/Library/Application Support/Google was owned by root:staff.

Fixed it by doing: sudo chown <user>:staff /Users/<user>/Library/Application Support/Google

IMO this is a better solution than relaxing the permissions of the folder with chmod 777 like others suggested.

If anyone still facing this issue give chmod 777 permission to the specified paths that error dialog is showing, in my case I had to give permission to Library/Logs and Library/Google

Example:

sudo chmod 777 ~/Library/Logs
sudo chmod 777 ~/Library/Google

I've encountered the same issue and here is the solution that worked for me. You need to navigate to where it was initially installed(if installed in the Application folder).

Run this command:

cd /Applications/Android\ Studio.app/Contents/MacOS

then

sudo ./studio

Related