Intellij Error: Internal caches are corrupted or h

2020-03-27 05:42发布

问题:

I am getting an error intermittently when I build my Java project in Intellij.

Internal caches are corrupted or have outdated format, forcing project rebuild: java.io.FileNotFoundException: C:\target\classes\ehcache.xml (Access is denied)

I have run File->Invalidate caches. I have restarted Intellij and killed all Java processes. I eventually get it to build again but not sure what thing I try does the trick.

When I try to access the 'Target' folder, it says Access Denied.

Anyone seen this before?

回答1:

As mentioned in my comment, I received the same message, but without any access right issues involved whatsoever.

It seemed to be some kind of confusion on IDEA's end. I was able to fix this by deleting the system directory in C:\Users\%USERNAME%\.IdeaIC13 (the path obviously depends on the IntelliJ IDEA version).

This stores all caches and indices among other things. I have to confess that I can't tell why exactly this helps, but it seems to be a rougher way to "invalidate caches" and it works. Your project history is not deleted this way, so you can practically continue working - just that all files have to be scanned again and all indices have to be rebuilt.

In any event, this was not an access rights problem at all.



回答2:

If you can't access the folder have to either change the rights for the entire hierarchy starting from your project root folder as described here, or move your project to some other directory that you are allowed to access



回答3:

For me, I just had to clean all modules (and ensure they didn't require sudo permission), and rebuild.

The File->Invalidate Caches/Restart... did not work for me.



回答4:

Tried all the above, but none worked for me. Finally running Intellij 14 in admin mode did the trick.



回答5:

I had this exact problem, I tried all of the above solutions but none of them worked for me.

The I tried the oldest one in the book (ie rebooting my laptop) and that fixed everything!



回答6:

Similar to pdinklag's answer, I had to delete my user-level Android Studio caches to get rid of this error. However, Android Studio caches are stored in ~/.android/.

I shut down Android Studio, then ran:

cd
rm .android/cache build-cache build-cache.lock

Then restarted Android Studio, and things worked.



回答7:

I had the same problem in Intellij 17 version for Mac. Rebuilding the project, changing the directory of the project, cleaning the module, and running IntelliJ 17 with admin mode did not work.

Updating Intellij to 2019 version solved the error. It seems the application was not able to get the admin permissions.