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

Remote container default search paths #1527

Closed
j3p0uk opened this issue Jul 5, 2021 · 9 comments
Closed

Remote container default search paths #1527

j3p0uk opened this issue Jul 5, 2021 · 9 comments
Labels
waiting for user response Requires more information from user

Comments

@j3p0uk
Copy link

j3p0uk commented Jul 5, 2021

Environment data

  • Language Server version: Pylance language server 2021.6.3 (pyright e66600b2)
  • OS and version: macOS Big Sur 11.4
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.9.6 64-bit Remote Containers 0.183.0

Expected behaviour

When installing requirements into the python environment in the remote container, the default search path for Pylance will pick it up and use it for source analysis.

Actual behaviour

Imports were not found even after pip install had run.

Logs

Code Snippet / Additional information

Adding this to the settings resolved the issue. It would be good to see this as default behaviour, or at least offer it as a possibility in the quick fix text

"python.analysis.extraPaths": [
  "/home/vscode/.local/lib/*/site-packages/"
]
@github-actions github-actions bot added the triage label Jul 5, 2021
@bschnurr
Copy link
Member

bschnurr commented Jul 5, 2021

can you provide the logs from "Python Language Server" output window with trace enabled?
https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

did you select the correct python interpreter or just using the default?

@bschnurr bschnurr added the waiting for user response Requires more information from user label Jul 5, 2021
@github-actions github-actions bot removed the triage label Jul 5, 2021
@j3p0uk
Copy link
Author

j3p0uk commented Jul 6, 2021

can you provide the logs from "Python Language Server" output window with trace enabled?
https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

Will do so, I didn't think it would provide much, as it seems very clear that the combination of remote container forcing pip install into the user-local location was just resulting in the pips being installed in a location not scanned by pylance by default, as I thought was confirmed by the workaround of adding it manually.

did you select the correct python interpreter or just using the default?

Given I'm using the remote containers plugin to build a container in which to run python for this, it selects the correct python interpreter by default. So yes, it is default, and it is also correct ;-)

@j3p0uk
Copy link
Author

j3p0uk commented Jul 6, 2021

  • Open window for python project.
  • Reopen in container.
  • Imports not found.
  • Open terminal (opens bash in remote container)
vscode ➜ /workspaces/es-logger (master ✗) $ pip install stevedore
Defaulting to user installation because normal site-packages is not writeable
Collecting stevedore
  Downloading stevedore-3.3.0-py3-none-any.whl (49 kB)
     |████████████████████████████████| 49 kB 594 kB/s 
Collecting pbr!=2.1.0,>=2.0.0
  Downloading pbr-5.6.0-py2.py3-none-any.whl (111 kB)
     |████████████████████████████████| 111 kB 5.3 MB/s 
Installing collected packages: pbr, stevedore
Successfully installed pbr-5.6.0 stevedore-3.3.0
vscode ➜ /workspaces/es-logger (master ✗) $ 
  • Imports still not resolved.
  • Add /home/vscode/.local/lib/*/site-packages/ to "python.analysis.extraPaths"
  • Imports now resolved.

Pylancelanguageser.log

@jakebailey
Copy link
Member

Pylance doesn't support * in extraPaths. See: #973

You shouldn't need to put site-packages into extraPaths; are you activating the interpreter that those paths are tied to?

@j3p0uk
Copy link
Author

j3p0uk commented Jul 6, 2021

Pylance doesn't support * in extraPaths. See: #973

Hmmm, I'll take another look.

You shouldn't need to put site-packages into extraPaths; are you activating the interpreter that those paths are tied to?

This is all done automatically by the reopening in a container. Prior to the switch to Pylance this just worked, which is very frustrating.

I'll take a look, I wonder is it just a delay in Pylance re-scanning.

@jakebailey
Copy link
Member

I'd check the bottom left to see which interpreter is being used. This should have affected any analysis, as they all rely on knowing the interpreter to then get paths.

@j3p0uk
Copy link
Author

j3p0uk commented Jul 6, 2021

I'd check the bottom left to see which interpreter is being used. This should have affected any analysis, as they all rely on knowing the interpreter to then get paths.

Yes, I am looking at that. The point about using a remote container, is that the container is built with a default python, and then that is supposed to be used for these dev tasks. This is indeed happening, the terminal and the language server all appear to be executing using the default python in the container. The problem is that the language server is not reacting when packages are installed. Having removed the additional search path, and then retesting by reloading the window after a pip install of a missing module, I can confirm it is simply that pylance is never refreshing state when new pip packages are installed.

@jakebailey
Copy link
Member

The problem is that the language server is not reacting when packages are installed. Having removed the additional search path, and then retesting by reloading the window after a pip install of a missing module, I can confirm it is simply that pylance is never refreshing state when new pip packages are installed.

Ah, that is a known bug, yes. See #923.

Note that there's a "restart language server" command you can use in the meantime to restart without fully reloading the editor.

@j3p0uk
Copy link
Author

j3p0uk commented Jul 6, 2021

Ah, that is a known bug, yes. See #923.

Note that there's a "restart language server" command you can use in the meantime to restart without fully reloading the editor.

Great, thanks for the fast attention. I guess adding the extra path must have made the language server restart and given the appearance of working.

I’ll make sure to add the pip install into the container builds to avoid in future. Thanks again!

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

3 participants