You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am attempting to use lsp-pyright with a monorepo and multiple venvs. There is an example repo here which can be used to demonstrate the problem. Specifically:
Clone the repo, and create two venvs, one for libs/base and one for libs/fancy. The specific instructions are here under the heading "Sandboxes". This should result in two .venv directories within the two library directories.
In emacs, open libs/base/adder2.py and ensure that lsp mode is active. This should start pyright.
Use lsp-workspace-folders-add to add the libs/base and libs/fancy folders.
Restart pyright.
If I understand correctly, the above steps should result in Pyright correctly able to resolve both internal and external dependencies. However it does not seem to. The problem, I believe, stems from setting the pythonPath incorrectly. Here is an extract from the *lsp-log* buffer.
Setting pythonPath for service "fancy": "/Users/alastair/hack/extern/python-monorepo-example/libs/base/.venv/bin/python"
Loading pyproject.toml file at /Users/alastair/hack/extern/python-monorepo-example/libs/fancy/pyproject.toml
Assuming Python version 3.11
No include entries specified; assuming /Users/alastair/hack/extern/python-monorepo-example/libs/fancy
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
Found 4 source files
Setting pythonPath for service "base": "/Users/alastair/hack/extern/python-monorepo-example/libs/base/.venv/bin/python"
Loading pyproject.toml file at /Users/alastair/hack/extern/python-monorepo-example/libs/base/pyproject.toml
Assuming Python version 3.11
No include entries specified; assuming /Users/alastair/hack/extern/python-monorepo-example/libs/base
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
Found 4 source files
Setting pythonPath for service "python-monorepo-example": "/Users/alastair/hack/extern/python-monorepo-example/libs/base/.venv/bin/python"
Loading pyproject.toml file at /Users/alastair/hack/extern/python-monorepo-example/pyproject.toml
Pyproject file "/Users/alastair/hack/extern/python-monorepo-example/pyproject.toml" is missing "[tool.pyright]" section.
Assuming Python version 3.11
Found 14 source files
Note specifically that the base venv is used for the fancy service. This is evident from the pythonPath setting.
Apologies if I have misunderstood something, but I believe this is a bug in lsp-pyright, and it should instead pick up the correct .venv directory for each workspace folder (a.k.a. service IIUC).
As an additional observation, I also attempted to get this to work by setting lsp-pyright-venv-directory and creating named venvs in that directory, with corresponding venv settings in each library's pyright.toml. This did not work either, as - again - the pythonPath was set to something completely different and incorrect, namely the system python instance.
The text was updated successfully, but these errors were encountered:
Hi, I am attempting to use lsp-pyright with a monorepo and multiple venvs. There is an example repo here which can be used to demonstrate the problem. Specifically:
libs/base
and one forlibs/fancy
. The specific instructions are here under the heading "Sandboxes". This should result in two.venv
directories within the two library directories.libs/base/adder2.py
and ensure thatlsp
mode is active. This should startpyright
.lsp-workspace-folders-add
to add thelibs/base
andlibs/fancy
folders.If I understand correctly, the above steps should result in Pyright correctly able to resolve both internal and external dependencies. However it does not seem to. The problem, I believe, stems from setting the pythonPath incorrectly. Here is an extract from the
*lsp-log*
buffer.Note specifically that the
base
venv is used for thefancy
service. This is evident from thepythonPath
setting.Apologies if I have misunderstood something, but I believe this is a bug in
lsp-pyright
, and it should instead pick up the correct.venv
directory for each workspace folder (a.k.a. service IIUC).As an additional observation, I also attempted to get this to work by setting
lsp-pyright-venv-directory
and creating named venvs in that directory, with correspondingvenv
settings in each library'spyright.toml
. This did not work either, as - again - the pythonPath was set to something completely different and incorrect, namely the system python instance.The text was updated successfully, but these errors were encountered: