Skip to content

env-vars in hatch config.toml not respected when resolving dependencies with pip-compile or uv #1959

@sudo-ankitmishra

Description

@sudo-ankitmishra

I'm using hatch with a private PyPI-compatible repository, and I'm trying to avoid hardcoding the PIP_EXTRA_INDEX_URL or UV_EXTRA_INDEX_URL directly in pyproject.toml (since the repo can change per environment).

Here's my setup:

os: macOs [tried on ubuntu as well]
hatch version: 1.13.0
python version: 3.12.7

[tool.hatch.env]
requires = ["hatch-pip-compile"]

[tool.hatch.envs.default]
type = "pip-compile"
lock-filename = "requirements.lock.txt"
pip-compile-hashes = true

I’ve tried setting the repo URL using the hatch global config file (~/.config/hatch/config.toml or ~/.hatch/config.toml):

[envs.default.env-vars]
PIP_EXTRA_INDEX_URL = "http://192.168.50.189:32009/simple"
UV_EXTRA_INDEX_URL = "http://192.168.50.189:32009/simple"

❌ Issues:

  • hatch shell does not expose these variables.
  • hatch env create or hatch run does not seem to pass them to the environment.
  • uv and pip-compile fail with "dependency not found" unless the repo is set inside [tool.hatch.envs.default.env-vars] in pyproject.toml.
  • Variables from the global config.toml are not respected during dependency resolution.

✅ What works:

  • Hardcoding the repo in pyproject.toml under [tool.hatch.envs.default.env-vars] works, but I want to avoid this since it's committed to version control.
  • Using a wrapper shell script with export works outside Hatch, but breaks the portability of the Hatch config and goes against its philosophy.

🔍 My expectation:

That PIP_EXTRA_INDEX_URL and UV_EXTRA_INDEX_URL set in global config should be respected during:

  • hatch env create
  • hatch run
  • any resolution using uv or hatch-pip-compile

Please let me know if:

  • I’m missing something in the configuration,
  • or if this is a bug/missing feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions