Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

How to make python-language-server able to analyze symlinked modules? #1545

Closed
ztlevi opened this issue Sep 15, 2019 · 4 comments
Closed

How to make python-language-server able to analyze symlinked modules? #1545

ztlevi opened this issue Sep 15, 2019 · 4 comments
Labels
question A question about the LS

Comments

@ztlevi
Copy link

ztlevi commented Sep 15, 2019

I found vscode is able to jump to definition over the symlinked modules. While other editors utilizing python-language-server can't.

How to enable the ability analyze symlinked modules? Do we need to pass extra params?

Thank you!

@jakebailey
Copy link
Member

I don't think that's something the language server is involved in. All the language server returns is the filename and location in that file, and the editor is expected to do the rest. If the editor can't open that file, then it'd be the editor with the issue. The language server doesn't have any issue analyzing symlinked files to my knowledge (and symlinks are how virtual environments work on Linux and macOS).

@ztlevi
Copy link
Author

ztlevi commented Sep 16, 2019

According to my test, vscode seems to utilize PYTHONPATH and use it to initialize the language server. And yes, it's capable of analyze symlinked modules.

So my question is, do we need to pass additional module paths to language server if the user has some modification on PYTHONPATH? If so, how?

@jakebailey
Copy link
Member

The extension sets the PYTHONPATH environment variable when it starts the language server. It also combines extraPaths and PYTHONPATH together and sends a list of search paths in the initialization options, although that is no longer required as of #1492 (as the LS will now read PYTHONPATH directly from its environment like any program).

If a language server client isn't starting with the environment of its parent process (which is presumably where you have PYTHONPATH set), then the LS wouldn't get that info. If your client is unable to set PYTHONPATH how you want it, you may also use extraPaths to specify the same list again, though there is currently more than one way to specify paths (still working to clean this up).

@ztlevi
Copy link
Author

ztlevi commented Sep 16, 2019

I see. I finally get it working now!

The problem is exactly my editor's (Emacs) language server didn't really utilizing PYTHONPATH as default. It has an additional variable lsp-python-ms-extra-paths to define extra package paths.

Thanks for the help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question A question about the LS
Projects
None yet
Development

No branches or pull requests

2 participants