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

Package installs not detected for interpreters / environments outside the workspace #923

Closed
blois opened this issue Feb 5, 2021 · 14 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@blois
Copy link

blois commented Feb 5, 2021

Environment data

  • Language Server version: 2021.2.0 (pyright e278f28d)
  • OS and version: OSX 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8, Conda 4.8.3
  • VSCode version: 1.54.0-insider

Expected behaviour

Start with a clean environment
Open a .py with

import jmespath

Correctly observe an error for the missing import.
Outside of the editor, install with pip install jmespath.

Expect the error to be resolved with no further action needed.

Actual behaviour

The error persists until the language server is restarted.

Logs

I was curious about where this was falling down because I run into it a lot. What I see is:

I don't really know the ins and outs of node file watchers, but at a glance I'm not sure when absolute paths are expected?

Omitted as the the logging I was able to get didn't seem useful based on analysis above.

Code Snippet / Additional information

This could be something with my filesystem I suppose? But I'm unable to get any other behavior anywhere else.

@github-actions github-actions bot added the triage label Feb 5, 2021
@jakebailey
Copy link
Member

We added that hack in to mirror the same hack in VS Code's own file watchers (linked in that above code); there's some goofiness in the way some OSs report their events and the "pattern" is that relative paths are bad events that need to be ignored.

How have you found that the event was a relative path? The event log comes after the isIgnored check, so I wouldn't have expected it to be printed...

@blois
Copy link
Author

blois commented Feb 5, 2021

I switched over to following the instructions from https://github.com/microsoft/pyright/blob/master/docs/build-debug.md#building-the-vs-code-extension and manually added logging (was a fun adventure). I think this is an appropriate approximation? The core issue was the same between the two, though it's entirely possible that the cause is different.

@jakebailey jakebailey added the needs investigation Could be an issue - needs investigation label Feb 5, 2021
@github-actions github-actions bot removed the triage label Feb 5, 2021
@jakebailey
Copy link
Member

Thanks. We've also had some internal reports about the library watching not working, so this is an interesting hint.

@blois
Copy link
Author

blois commented Feb 5, 2021

I'm curious if this is a difference between the Node & the Chokidar file system watchers.

@jakebailey
Copy link
Member

It's possible this regressed (or never worked) as we mainly test with virtual environments within the workspace, as opposed to the conditions where packages are installed in global (or pipenv/conda) locations outside the workspace.

I do recall there was a reason why we prefer the built-in node watcher over chokidar for this purpose, but I can't recall why off the top of my head.

@erictraut
Copy link
Contributor

The node and chokidar file system watchers unfortunately each have different quirks, limitations, and bugs (some of them resulting in crashes). And those differ by platform. We've done our best to select the best options and configure them in the best way, but there's no great answer here.

For the Pyright VS Code extension, I exposed a "Restart language server" command, and I use it to work around cases like this where the file system watcher doesn't work. We may want to expose the same command in Pylance.

@jakebailey
Copy link
Member

We already do have one, I implemented it a few months ago.

I think I want to reexamine the file watching code; pyright originally did use chokidar but it was changed when we were starting on Pylance. That and the FS code is flipped around. I have a branch I'm working on to pick up Monday.

@jakebailey
Copy link
Member

This does come down to a difference in the file watcher interfaces; I did some live checking with @rchiodo and switching it to Chokidar does make this work again. I'll do some testing to verify this doesn't regress anything.

@jakebailey jakebailey added the bug Something isn't working label Feb 8, 2021
@jakebailey jakebailey self-assigned this Feb 8, 2021
@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Feb 10, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.2.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202121-10-february-2021

@jakebailey
Copy link
Member

Reopening; we unfortunately had to revert the file watcher change as it caused too many issues on macOS (and potentially others).

For now, a workaround is to use the "Restart language server" command, which should be as efficient as letting the file watcher reload things, but obviously isn't automatic. (Better than a full reload.)

@jakebailey jakebailey added needs investigation Could be an issue - needs investigation and removed fixed in next version (main) A fix has been implemented and will appear in an upcoming version labels Feb 17, 2021
@hans2520

This comment has been minimized.

@jakebailey

This comment has been minimized.

@Fatsie
Copy link

Fatsie commented May 28, 2021

As I reported in #1357 I have seen same problems but for me it was on Ubuntu 20.04, Pylance 2021.5.4

@jakebailey jakebailey changed the title Library additions not automatically detected Package installs not installed for interpreters / environments outside the workspace Sep 1, 2021
@jakebailey jakebailey changed the title Package installs not installed for interpreters / environments outside the workspace Package installs not detected for interpreters / environments outside the workspace Sep 1, 2021
@heejaechang
Copy link
Contributor

dup this to #2505

@heejaechang heejaechang added duplicate This issue or pull request already exists and removed needs investigation Could be an issue - needs investigation labels Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

8 participants