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

Python language features not working with mounted folder via sshfs #1538

Closed
alexbogun opened this issue Jul 7, 2021 · 20 comments
Closed

Python language features not working with mounted folder via sshfs #1538

alexbogun opened this issue Jul 7, 2021 · 20 comments
Labels
waiting for user response Requires more information from user

Comments

@alexbogun
Copy link

Environment data

  • VS Code version: 1.57.1
  • Extension version: v2021.6.944021595
  • OS and version: Ubuntu 18.04 (and WSL 2 on Windows 10)
  • Python version: 3.8
  • Type of virtual environment used : conda
  • Value of the python.languageServer setting: tried all of them

Expected behaviour

Intellisense (code completion) and lining working properly always

Actual behavior

When I have a folder opened (project_folder) in VS-Code AND I have a mounted directory via sshfs INSIDE of this project_folder the following features are not working in any Python file:

  • Intellisense (code completion) (no matter which language server selected)
  • Linting (no matter which linter selected)
  • Looking up function definition
  • Mouseover hints

Basically, the only Python-specific feature that IS working is syntax highlighting, other than that it is as if language is not selected.

If there are no mounted directories in project_folder OR if VS-Code does not have folder opened (e.g. I directly open file via file->open) everything works as expected.

I assume this is somehow related to python search path, i.e. something is trying to search the current path, gets to the mounted folder and somehow fails. Strangely this does not happen if VS-Code is not in an opened folder mode.

I have tried all Python language servers with the same result.
I have also tried to look into language server and extension logs on remote, but have not found anything wrong.
I have also tried it on WSL2-Ubuntu18 and on Ubuntu18 proper with the same outcome.
Everything has worked fine a couple of months ago, so something must have been changed recently.

Steps to reproduce:

  1. open a folder in VS-Code
  2. mount a directory (inside of opened folder) to remote server via sshfs
  3. create Python file
  4. type "import os"
  5. type "os."
  6. press ctrl+space
  7. Intellisence not working ("Loading..." appears forever)

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Jul 8, 2021
@github-actions github-actions bot added the triage label Jul 8, 2021
@jakebailey
Copy link
Member

I believe this is a duplicate of #962.

@alexbogun
Copy link
Author

alexbogun commented Jul 8, 2021

@jakebailey could you please elaborate on how is this related to #962?

My problem happens when working on the Linux machine directly without a remote interpreter.

You might have misunderstood, I am not working via ssh remote extension, I am working directly on a Linux machine, it is only that I have a folder mounted via sshfs to another system. I have only mentioned WSL2 because this problem occurs on that system as well, so it must be replicable.

@jakebailey
Copy link
Member

Whose "sshfs" are you referring to? Provided by VS Code, or is it a mount in the FS directly via FUSE or similar?

@jakebailey jakebailey reopened this Jul 8, 2021
@jakebailey jakebailey added the waiting for user response Requires more information from user label Jul 8, 2021
@github-actions github-actions bot removed the triage label Jul 8, 2021
@alexbogun
Copy link
Author

@jakebailey Thanks for reponening.
I indeed, refer to the mount in the FS directly via FUSE.
My suspicion is that having such mount on the Python path breaks something in the language server.
However, strangely, as written above it is only happening when VS Code has a folder open (via Open Folder...) and the sshfs mounted directory is in this folder.

@jakebailey
Copy link
Member

That is strange; if you're just FUSE mounting, we shouldn't really treat it any differently than another directory. Sorry to close; VS Code has an SSHFS system that's virtual, but if you're on disk, then we should be able to work as expected.

Since this issue was transferred, can you enable trace logging and provide Pylance's logs? Our issue instructions are mirrored here: https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

@alexbogun
Copy link
Author

Yeah there is indeed something wrong with pathing here.
"/home/abogun/Shares/dgx" is the mounted folder via sshfs.

@alexbogun
Copy link
Author

[Info - 9:00:37 PM] Pylance language server 2021.7.2 (pyright adb49aaa) starting
[Info - 9:00:37 PM] Server root directory: /home/abogun/.vscode/extensions/ms-python.vscode-pylance-2021.7.2/dist
[Info - 9:00:37 PM] No configuration file found.
[Info - 9:00:37 PM] No pyproject.toml file found.
[Info - 9:00:37 PM] Setting pythonPath for service "ensemble": "/home/abogun/miniconda3/bin/python3.7"
[Warn - 9:00:37 PM] stubPath /home/abogun/Shares/dgx/abogun/ensemble/typings is not a valid directory.
[Info - 9:00:38 PM] Assuming Python version 3.7
[Info - 9:00:38 PM] Assuming Python platform Linux
Search paths for /home/abogun/Shares/dgx/abogun/ensemble
/home/abogun/.vscode/extensions/ms-python.vscode-pylance-2021.7.2/dist/typeshed-fallback/stdlib
/home/abogun/Shares/dgx/abogun/ensemble
/home/abogun/Shares/dgx/abogun/ensemble/typings
/home/abogun/.vscode/extensions/ms-python.vscode-pylance-2021.7.2/dist/typeshed-fallback/stubs/...
/home/abogun/.vscode/extensions/ms-python.vscode-pylance-2021.7.2/dist/bundled/stubs
/home/abogun/miniconda3/lib/python3.7
/home/abogun/miniconda3/lib/python3.7/lib-dynload
/home/abogun/miniconda3/lib/python3.7/site-packages
[Warn - 9:00:38 PM] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
[Warn - 9:00:38 PM] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
[Warn - 9:00:38 PM] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
[Info - 9:00:38 PM] Searching for source files

@alexbogun
Copy link
Author

Might be somehow related to this one: microsoft/pyright#1159

@jakebailey
Copy link
Member

The file watching error is a red herring, and only matters for library watches for package installs, which is #923.

If that's the end of the log, it's stopping at the source file discovery phase. Does this folder contain any symlinks that go to large folders somewhere else?

@alexbogun
Copy link
Author

Yes I mean the "/home/abogun/Shares/dgx" is the mount to a huge folder on a server (different from the host machine).

I have tried again with not having folder opened in VS code, but rather opening just the file, and language server works fine.

After
[Info - 9:11:04 PM] Searching for source files

Follows this
[Info - 9:11:04 PM] No source files found.
[Info - 9:11:04 PM] Background analysis(1) root directory: /home/abogun/.vscode/extensions/ms-python.vscode-pylance-2021.7.2/dist
[Info - 9:11:04 PM] Background analysis(1) started

and much more.... but everything works fine

@jakebailey
Copy link
Member

Single file mode means we won't have a workspace to scan, so that's why that appears to work (but has its own problems; #1300 and others).

dgx may be huge, but I'm specifically talking about the folder you're opening; we only look at files in the workspace, but if there are symlinks that go out, we may be getting stuck.

@alexbogun
Copy link
Author

The folder I am opening "ensemble" is inside of "dgx" mount, but as far as I know, it should not have any symlinks.
However, it is a very large folder, it contains tens of thousands of files and is probably has a size in terabytes (still running "du", so cannot even tell how large it is).

@alexbogun
Copy link
Author

there are however symlinks on my system path. I mean in my Linux home directory there is a symlink to a folder elsewhere.

@alexbogun
Copy link
Author

Still, I have this setup for quite some time and everything used to be fine.

@erictraut
Copy link
Contributor

My guess is that pylance is enumerating the files in the workspace, and it's taking a very long time because it's remote and there are many files and directories to scan.

@alexbogun
Copy link
Author

Yeah, this seems plausible, is there a way to exclude directories from the workspace?

@jakebailey
Copy link
Member

However, it is a very large folder, it contains tens of thousands of files and is probably has a size in terabytes (still running "du", so cannot even tell how large it is).

The number of files is the key thing; I'm guessing the number of files is compounding with the SSHFS overhead and making it slow to do the workspace scan.

Still, I have this setup for quite some time and everything used to be fine.

Are you saying that this is a new change and was working in a previous version of Pylance, or that you have just started using Pylance and you're seeing this?

Given this was transferred, you may have been using Jedi previously ("python.languageServer": "JediLSP" or similar).

@jakebailey
Copy link
Member

Yeah, this seems plausible, is there a way to exclude directories from the workspace?

Yes, with a pyrightconfig.json in your workspace root and an exclude configuration: https://github.com/microsoft/pyright/blob/main/docs/configuration.md#main-pyright-config-options

@alexbogun
Copy link
Author

This issue happens with every Language Server I have tried.
I do not know for sure what has changed. VS Code and Python extension evolve, but my folder did grow quite a bit in the last moths.
I will try to exclude all the large directories and will report back.
Thanks for pointing me to a way to exclude directories.

@alexbogun
Copy link
Author

Yeah, putting all large directories inside pyrightconfig.json exclude section, solved everything.

Note to self: I should have put code not in the parent folder of a project but in a subfolder "code" and open that in VSCode.

Thank you for your help. Much appreciated!

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