# Fix \`PythonLocator\` to pass through \`env\` variables from the task template \(\#63154\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/49a841c7ad42cfb605d000bfa7b35a9ef9ec33ab)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 49a841c7ad42cfb605d000bfa7b35a9ef9ec33ab

Requested commit: 49a841c7ad42cfb605d000bfa7b35a9ef9ec33ab

Commit: 49a841c7ad42cfb605d000bfa7b35a9ef9ec33ab

Tree: 71afc785e203b12e2d38ced14c6c0c2860e71c9a

Author: Andrey Fedoseev

Committer: GitHub

## Message

````
Fix `PythonLocator` to pass through `env` variables from the task template (#63154)

This matches `GoLocator` and `NodeLocator`

# Objective

The problem: `env` variables defined in `tasks.json` aren't used when
the task runs in debug mode.

Example:

```json
[
  {
    "label": "pytest (custom)",
    "env": {
      "DATABASE_URL": "...",
    },
    "command": "$ZED_CUSTOM_PYTHON_ACTIVE_ZED_TOOLCHAIN",
    "args": [
      "-m",
      "pytest",
      "$ZED_CUSTOM_PYTHON_TEST_TARGET",
    ],
    "tags": ["python-pytest-class", "python-pytest-method"],
    "cwd": "$ZED_WORKTREE_ROOT",
  },
]
```

When a test runs normally, the `DATABASE_URL` variable is set correctly.
When the test runs in debug mode, the variable is not set.

## Solution

`PythonLocator` copies the `env` value from the `TaskTemplate`. This
matches other locators, such as `GoLocator` and `NodeLocator`

## Testing

- Did you test these changes? If so, how?
  - The existing integration test is updated to verify the change
- Are there any parts that need more testing?
  - No
- How can other people (reviewers) test your changes? Is there anything
specific they need to know?
- Run `cargo test -p project --test integration
debugger::python_locator::test_python_locator`
- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?
  - Linux (NixOS), the change is platform-agnostic.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

N/A

---

Release Notes:

- Fix `PythonLocator` to pass through `env` variables from the task
template
````

## Parents

- [a170a12414771c45ccb8271f14a93553ea742115](https://git.cafe/gitcafe/zed/commit/a170a12414771c45ccb8271f14a93553ea742115?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/49a841c7ad42cfb605d000bfa7b35a9ef9ec33ab?format=markdown)
