Cannot find declaration to go to (solved)


File -> settings -> Project Interpreter -> show all > + system interpreter
File -> settings -> Project structure -> cancel all checked and set only root as a source
File -> invalidate caches
must ok
by Jesse Stone


It didn't work for me 


Same for me: not working whereas everything was fine (without any parameter update by the way) in previous versions of PyCharm


I also see the message "Cannot find declaration to go to" and all suggested solutions do not work.


In my case the problem was the next: for some reasons *.py files were registered as a text files, not python ones. After I changed it, code completion started to work again.

To change file type go Preferences -> Editor -> File types


Working in Unity/C#.

Did an update this morning to 2022.3.3, once upgraded & restarted, PC too, I got a pop up about invalidate caches, my typically colorful code was very blah looking, nothing was highlighting correctly, so I took the suggestion and restarted. 


Opened Rider again and same, I could not F12, jump to my methods, Rider was saying "could not find declaration". 

I looked that up and and got here. 

Followed the File -> invalidate caches and that didn't work.

Eventually, what worked for me, and not sure this is completely logically, but did work so this is why I'm posting: I usually have 6-12 code windows opened, so I closed each one, then closed Rider, relaunched Rider from within Unity and finally saw all my code highlighted in the correct way and was able to start working again!  [Definitely a bit freaked out!!]


Hey, I'm working with RubyMine under Windows 11's WSL2 (Ubuntu 22.04) and I'm using rbenv as a ruby version manager. I also had the problem with cannot find declaration to go to which I resolved by adding Ruby version as an wsl2 interpreter and synchronize gems and RubyMine helper files - Settings > Language and Frameworks > Ruby SDK and Gems, then add rbenv's Ruby e.g. \\wsl$\Ubuntu-22.04/home/<User>/.rbenv/versions/3.1.3/bin/ruby and after that hit ctrl+r or the red download arrow next to the list.  Hopefully it will be of some use for future same-problem-having users :)


In my case the “.php” file extension was associated with the text content type. Adding “*.php” to “file name patterns” under “Settings → File Types → PHP” has fixed it for me.


@Raphael Minato does it help if you invalidate caches? (File | Invalidate chache..)? If not, please file a bug at with the issue details.


Maxim Yushin Please contact support at with the sample to reproduce and the logs (Help | Collect Logs and Diagnostic Data).


Please sign in to leave a comment.