LSP reports errors not found by `pyrefly check` in monorepo
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
I'm seeing inconsistent behavior between `pyrefly check` and the LSP integration in my editor in a monorepo project with several pacakges. First, the LSP reports `missing-import` for third-party imports. Second, though I believe this is actually caused by the first error, I get various type errors related to the types I'm importing from other packages in the monrepo as if it isn't actually loading those files correctly. `pyrefly check` is able to check the code and reports no errors.
I have a global `pyrefly.toml` at the top of the repository.
I'm using nix to define the development environment, so there is not a normal virtualenv. The `python` that's available on the path has all of the third-party packages in its `site-packages` directory however.
`pyrefly dump-config` output, shortened by replacing the fully-qualified path of the repository root with `$PWD`:
```
Configuration at `$PWD/pyrefly.toml`
Using interpreter: /nix/store/ms54xjlpcz75amf8iii8isjs8n47ijy3-devshell-dir/bin/python3
Covered files:
$PWD/ap_feeds/src/ap_feeds/__init__.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/ap_feeds/src/ap_feeds/xxx.py
$PWD/apiary_inspection/src/apiary_inspection/__init__.py
$PWD/apiary_inspection/src/apiary_inspection/xxx.py
$PWD/apiary_inspection/src/apiary_inspection/xxx.py
...and 88 more
Resolving imports from:
Search path (from config file): ["$PWD/ap_feeds/src", "$PWD/apiary_inspection/src", "$PWD/apiary_messages/src", "$PWD/apiary_prelude/src"]
Import root (inferred from project layout): "$PWD"
Site package path queried from interpreter: ["$PWD/apiary_app/src", "$PWD/apiary_external_knowledge/src", "$PWD/scripts/src", "$PWD/mars_base/src", "$PWD/apiary_inspection/src", "$PWD/apiary_methods/src", "$PWD/apiary_messages/src", "$PWD/apiary_prelude/src", "$PWD/ap_feeds/src", "$PWD/apiary_scheduler/src", "$PWD/analysis/src", "$PWD/gather_statistics/src", "$PWD/certificate_authority/src", "$PWD", "/nix/store/fxafmpnikkzsrhsymrwxx6lch8bcslc3-python3-3.13.14-env/lib/python3.13/site-packages"]
```
This looks how I would expect.
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
I'm using emacs 30.2 with the built-in eglot language server client.
Contributor guide
Research direction
Start by reproducing the discrepancy with the repository's global pyrefly.toml, comparing pyrefly check and the LSP through Emacs eglot; use pyrefly dump-config to verify interpreter, search paths, and covered files. Done means the LSP resolves the third-party and monorepo package imports consistently with pyrefly check and no longer reports the described errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100