Stop continuous indexing of .pub-cache directory in PyCharm

Answered
~/.pub-cache is the location of Dart SDK libraries. When running pub get, a directory is created (packages) containing the symbolic links to libraries in .pub-cache. PyCharm attempts to index these libraries. It does so on start up, but continues to re-index ad infinitum.

Here is the fix to this issue:

In order to stop PyCharm from constantly indexing .pub-cache, first remove the .pub, .packages, and packages directories from your project directory:
 
cd path/to/project/frontend
rm -rf .pub .packages && find . -name packages | xargs rm -rf
pub get --packages-dir
 
Next invalidate the cache in PyCharm and restart:
 
File > Invalidate Caches / Restart... > Invalidate and Restart
 
After an initial indexing, PyCharm should no longer attempt to re-index the .pub-cache directory.
1
5 comments
Official comment

What Dart SDK version do you use? And what IDE version?

'packages' folder with symlinks has gone ages ago.

As of now .packages file is the canonical source of truth. IDE auto-creates 'Dart Packages' library that contains paths listed in .packages file. So IDE indexes only those packages from .pub-cache that are explicitly referenced in your project. And it should do it only once in a life. 

If you are using up-to-date IDE and SDK version then please attach logs (Help | Show Log), and also .idea folder and *.iml files zipped.

Ah, just noticed that you use  --packages-dir flag. What are reasons of doing it?

0
Avatar
Permanently deleted user

The application does not build without the --packages-dir flag.

0

Is there an issue in the Dart SDK's issue tracker? I think they are not going to support this flag forever.

As for the original problem (constant reindexing) - as far as I understand it has been resolved after invalidating caches and restart, right? 

0
Avatar
Permanently deleted user

Correct. Thus, why I posted this. Googling the issue yielded no viable results. This post is for posterity.

0

Please sign in to leave a comment.