Configuring path priority for code indexing

In PyCharm 2019.3 and 2020.1 EAP, the configured libraries for my remote interpreter seem to always have higher priority when it comes to code indexing. If I have

  1. Local project source: "foo/bar.py
  2. Remote interpreter's remote libraries: "my_library_path/foo/bar.py" (an older version of the file that I'm writing updates to in the local project source)

then PyCharm will "prioritize" the remote library version of the file. This means click-to-definition and function signature validation will reference "/Users/<user>/Library/Caches/PyCharm2019.3/remote_sources/470894275/-399348569/foo/bar.py".

It seems like it should be pretty obvious that project files should have priority, or at the very least the path priorities should be configurable. 2019.2 does not have this issue. Is there a workaround or some configuration for this somewhere?

 

(Thankfully, with JB Toolbox it's pretty easy to switch between versions!)

14 comments
Comment actions Permalink

Did you install remote libraries as editable by any chance (pip install -e) ?

There's a known issue for that: https://youtrack.jetbrains.com/issue/PY-25868

0
Comment actions Permalink

Andrey Resler no. I added them as "remote libraries" for the interpreter by selecting a path on the remote host. If I ever try to edit them locally PyCharm tells me the file is not edittable.

0
Comment actions Permalink

>I added them as "remote libraries" for the interpreter by selecting a path on the remote host.

Could you please provide a screenshot of how you configured that? Did you edit interpreter paths (https://www.jetbrains.com/help/pycharm/python-interpreters.html#paths) ?

 

0
Comment actions Permalink

 Andrey Resler Yes I added to the remote interpreter paths.

 

0
Comment actions Permalink

ping Andrey Resler =)

 

I would love to use a more recent version of PyCharm but this is absolutely a blocker for me.

0
Comment actions Permalink

Hey, sorry for the delayed reply.

In the meantime I tried to reproduce the issue with similar setup, but wasn't successful, everything working fine on my side. 

Anyway, I wonder why is there a need to add this interpreter path? Wouldn't it work otherwise? Please try to:

1. Delete the custom path from interpreter paths

2. Do "File | Invalidate caches / restart"

3. Try going to declaration on your sources - does it still navigate to the remote_sources?

4. Does your run configuration still work?

0
Comment actions Permalink

Andrey Resler I need to add this interpreter path because there are a bunch of dependencies that get pulled in from the build tool that are outside of the paths I sync to my devserver. It is not feasible to have a local checkout of the monorepo because it will slow PyCharm to a crawl and take up far too much space on my laptop. If I remove the interpreter path I'll get red squiggles all over the codebase and I won't be able to do go-to-definition for any of those files.

To be fair, the SFTP file transfer for the build tree built into PyCharm is so slow that I actually wrote a script to read the PyCharm config xml and do an rsync to fetch the relevant files =D

0
Comment actions Permalink

Andrey Resler ping (pong) =D

0
Comment actions Permalink

Hey,

I managed to reproduce the issue, but this may be an expected behavior. Do you have foo/bar.py actually accessible from your remote project root? The local project project structure and remote project structure should be identical for all resolutions to work correctly. Please confirm if this is the case.

If you add an external package (not from project directory) to interpreter paths, PyCharm considers it a remote source, therefore ignoring the local package.

0
Comment actions Permalink

Andrey Resler if I'm understanding you correctly then yes `foo/bar.py` is accessible in that added remote interpreter path. I also have my deployment set up where doing "sync to remote" uploads and downloads files correctly. Is there something else you meant by "remote project root"? Is that something that is configurable in PyCharm2020? As far as I understand the deployment structure isn't related to how PyCharm does file resolution.

The external remote sources directory shares the same structure as my local sources directory. To be clear:

  1. Remote source file: /buck-out/gen/libra_wallet/all_deps_DO_NOT_IMPORT#binary,link-tree/foo/bar.py
  2. Local file: /Users/akant/fb_projects/libra_wallet/fbcode/foo/bar.py
  3. Remote interpreter path: /buck-out/gen/libra_wallet/all_deps_DO_NOT_IMPORT#binary,link-tree
  4. /Users/akant/fb_projects/libra_wallet/ is the local path to my PyCharm project
  5. fbcode and all_deps_DO_NOT_IMPORT#binary,link-tree/ should be considered the same root as far as Python files are concerned. PyCharm seems to understand the package structures just fine, it's just that it is prioritizing the files in the remote interpreter path.
  6. fbcode is marked as a source directory for the PyCharm project
0
Comment actions Permalink

Reproduced and reported: https://youtrack.jetbrains.com/issue/PY-42435

Please follow the issue.

0
Comment actions Permalink

Thank you very much! I am super excited to move to a new version of PyCharm once this is fixed!

0
Comment actions Permalink

The developer has posted a comment requiring your attention, please reply when you have time.

0
Comment actions Permalink

Andrey Resler can you try to prod the development team on this? This has been a thorn in my side for well over a year now and no one is responding to the YouTrack.

 

Thanks!

0

Please sign in to leave a comment.