zed/crates/dap_adapters
David Alecrim 7aec07ccde
dap_adapters: Add envFile support to Python debug adapter (#52933)
Closes #52912

## Context

The Python debug adapter listed `envFile` in its schema (defaulting to
`${ZED_WORKTREE_ROOT}/.env`) but never read it. Debugpy only accepts
`env`
as a key-value object — `envFile` is a VS Code extension concept that
Zed
needs to handle itself, same as the Go adapter already does for Delve.

## Changes

Added `handle_envs` to `crates/dap_adapters/src/python.rs`:

- Reads `envFile` (string or array), parses with `dotenvy`, merges into
`env`
- Explicit `env` values win on conflict with `envFile`
- Strips `envFile` before the config reaches debugpy
- Called after `cwd` is resolved so relative paths work

Two `FakeFs` tests cover the happy path and the conflict case.

No `Cargo.toml` changes needed.

## Usage

```json
[{
  "label": "Debug main.py",
  "adapter": "Debugpy",
  "request": "launch",
  "program": "${ZED_FILE}",
  "envFile": "${ZED_WORKTREE_ROOT}/.env"
}]
```

## Before
<img width="1512" height="954" alt="before"
src="https://github.com/user-attachments/assets/0b6c6353-fdac-4f09-a424-2e9651a08912"
/>

## After
<img width="1512" height="947" alt="after"
src="https://github.com/user-attachments/assets/8f354a5e-7ac7-432b-8293-3571fecf263b"
/>

Release Notes:

- Fixed `envFile` not being loaded when debugging Python projects with
debugpy

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2026-10-05 10:53:02 +00:00
..
src dap_adapters: Add envFile support to Python debug adapter (#52933) 2026-10-05 10:53:02 +00:00
Cargo.toml Remove some unnecessary dependencies (#64862) 2026-09-28 08:56:15 +00:00
LICENSE-GPL Debugger implementation (#13433) 2025-03-18 12:55:25 -04:00