zed icon indicating copy to clipboard operation
zed copied to clipboard

Python: project not recognizing packages installed in the `.venv` specified by `pyproject.toml`

Open ramipellumbi opened this issue 7 months ago • 7 comments

Summary

One of the last few releases broke [tool.pyright] .venv detection in Zed.

I have a monorepo with multiple Python projects that had each project identify the virtual environment via a local pyproject.toml. Now, that behavior no longer works. This is broken on MacOS and Linux.

Description

Steps to reproduce:

  1. Clean Zed install
  2. Create a Python project using uv. E.g., uv init --lib myproject. Run uv sync from the myproject directory to generate the .venv (add whatever package you want).
  3. Add to the pyproject.toml
[tool.pyright]
venvPath = "."
venv = ".venv"

Expected Behavior: Expect pyright to respect the .venv packages Actual Behavior: pyright does not respect the .venv

Zed Version and System Specs

Zed: v0.148.8 (Zed) OS: macOS 15.3.2 Memory: 64 GiB Architecture: aarch64

ramipellumbi avatar Apr 30 '25 19:04 ramipellumbi

Seems this is because of https://github.com/zed-industries/zed/pull/29662. What is the recommended approach for this use case by the Zed team now? I am currently pinned to v0.183.12, where I can effectively use Zed to manage my codebase.

ramipellumbi avatar Apr 30 '25 19:04 ramipellumbi

Probably related: I have basically the same issue now in this repo for example (not a monorepo).

Previously I did not need the [tool.pyright] config for stuff to work (I use mypy, it's nice to not have both mypy and pyright config if possible, although it's only 3 lines), but installed packages are not recognized without it now.

volfpeter avatar May 05 '25 07:05 volfpeter

Perhaps related, on a remote session over ssh I cannot detect the local project venv or global venv as an interpreter. It only shows system defaults in the dropdown.

stockeh avatar May 08 '25 07:05 stockeh

So, I had ‘ruff’ set as the language server in my global configuration, but on the remote host, it always uses ‘pyright’. And here’s the catch: even if I change global configuration settings related to the language and language server on an SSH session, it doesn’t work. I have to make the changes either in the global configuration inside the remote host or in the project-level configuration. Is this the intended behavior?

haruishi43 avatar May 12 '25 00:05 haruishi43

Hey @haruishi43 and @stockeh, would you please open new issues for the ruff/pyright configuration issues you're describing? Please include your settings json and steps to reproduce in your issues. They may be related, however they are worth tracking separately. Thanks!

probably-neb avatar May 12 '25 05:05 probably-neb

I don't want to bloat the issue tracker, so I just commented here with all my settings and how I can reproduce the problem.

volfpeter avatar May 12 '25 09:05 volfpeter

This was the approach I was using to get around the lack of support for .venvs in a monrepo or nested project structure and is the underlying reason for this isssue here... https://github.com/zed-industries/zed/issues/30135

This is currently the most painful issue in Zed for me.

bkgthumanity avatar May 12 '25 15:05 bkgthumanity

@probably-neb sorry for the late reply. Searching other issues again, I think my issue is more related to this one: https://github.com/zed-industries/zed/issues/29705

haruishi43 avatar May 16 '25 23:05 haruishi43