Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global module import for multi root workspace #1423

Closed
Griperis opened this issue Jun 10, 2021 · 4 comments
Closed

Global module import for multi root workspace #1423

Griperis opened this issue Jun 10, 2021 · 4 comments
Labels
waiting for user response Requires more information from user

Comments

@Griperis
Copy link

Hello,
I have read through several issues and didn't find an answer or resolved what is or should be correct behaviour for this case.

We have a multi-root workspace with several folders defined in .code-workspace (fld1, fld2) settings and one third party folder which contains modules.

root/xyz/fld1/file.py
root/uvw/fld2/file.py
root/3rd/module

Having settings with python.analysis.extraPaths: ["3rd/module"] resolves into a separate 'search path' for each workspace folder instead of for the root workspace as I would have expected.

Environment data

  • Language Server version: 2021.6.1
  • OS and version: Windows 10.0.19043
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9

Expected behaviour

Search paths passed to pylance:

fld1/
/3rd/module

The path from extraPaths is absolute to the workspace and is not dependent on the workspace folder path, where the currently edited python file lies.

Actual behaviour

Search paths passed to pylance:

fld1/
fld1/3rd/module

The /3rd/module path is appended to the fld1 or fld2 path depending on the place where the python file is edited.
I would expect using python.analysis.extraPaths: ["./3rd/module"] is going to result in this behaviour instead, but it works the same.

@Griperis Griperis changed the title Global package import for multi root workspace Global module import for multi root workspace Jun 10, 2021
@jakebailey
Copy link
Member

jakebailey commented Jun 10, 2021

I think that this is working as expected. The paths 3rd/module and ./3rd/module are the same path. Path-related settings are rooted relative to the workspace. Paths inherited from a code-workspace or user settings.json file are not distinguishable from per-workspace settings.

When you're using multi-root workspaces, you have multiple workspaces, each with their own roots. You would need to configure each of their settings individually. Can you try specifying the paths per-root instead? i.e. in each's settings, versus in code-workspace?

@jakebailey jakebailey added the waiting for user response Requires more information from user label Jun 10, 2021
@github-actions github-actions bot removed the triage label Jun 10, 2021
@Griperis
Copy link
Author

Griperis commented Jun 11, 2021

I think then that's my misunderstanding of how VSCode workspaces work. I expected that there is a root workspace containing some other workspaces defined in the .code-workspace "folders", isn't that the case? Isn't there an ability to have 'root workspace' settings applied for every workspace the same way and then relative settings in the sub-workspaces?

Using settings individually is for sure possible, but I don't think that it scales well with our approach. Adding one library results in adding multiple paths at multiple files.

@jakebailey
Copy link
Member

VS Code configuration is layered; when you query it, you get the setting for the specific workspace, then if not present, the setting from code-workspace, then if not present, the user configuration. From the querier's point of view, you're just getting a value back. Language servers get that final merged information and have no idea that the setting was set it one place versus another and that maybe the intent was for it to be relative to some other locations.

There are things we can do to try and ask VS Code for the raw settings at each layer, but this is sort of leaving the realm of the way that VS Code settings and the LSP were designed.

@Griperis
Copy link
Author

Seems that my expectations are against the design of VSCode. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

2 participants