Summary
It seems that environments setting in uv.toml is ignored when writing uv.lock.
MWE:
In an empty directory in a linux environment execute:
cat << EOF > uv.toml
environments = ["sys_platform == 'linux'"]
EOF
uv init
uv add ruff
grep win uv.lock
Output:
Initialized project `test-uv`
Using CPython 3.13.1
Creating virtual environment at: .venv
Resolved 2 packages in 73ms
Installed 1 package in 86ms
+ ruff==0.12.5
{ url = "https://files.pythonhosted.org/packages/3e/b9/053d6445dc7544fb6594785056d8ece61daae7214859ada4a152ad56b6e0/ruff-0.12.5-py3-none-win32.whl", hash = "sha256:dfeb2627c459b0b78ca2bbdc38dd11cc9a0a88bf91db982058b26ce41714ffa9", size = 11751575, upload-time = "2025-07-24T13:26:30.835Z" },
{ url = "https://files.pythonhosted.org/packages/bc/0f/ab16e8259493137598b9149734fec2e06fdeda9837e6f634f5c4e35916da/ruff-0.12.5-py3-none-win_amd64.whl", hash = "sha256:ae0d90cf5f49466c954991b9d8b953bd093c32c27608e409ae3564c63c5306a5", size = 12882273, upload-time = "2025-07-24T13:26:32.929Z" },
{ url = "https://files.pythonhosted.org/packages/00/db/c376b0661c24cf770cb8815268190668ec1330eba8374a126ceef8c72d55/ruff-0.12.5-py3-none-win_arm64.whl", hash = "sha256:48cdbfc633de2c5c37d9f090ba3b352d1576b0015bfc3bc98eaf230275b7e805", size = 11951564, upload-time = "2025-07-24T13:26:34.994Z" },
Compare to adding the same environments setting to pyproject.toml
cat << EOF >> pyproject.toml
[tool.uv]
environments = ["sys_platform == 'linux'"]
EOF
uv sync
grep win uv.lock
Output:
warning: Found both a `uv.toml` file and a `[tool.uv]` section in an adjacent `pyproject.toml`. The following fields from `[tool.uv]` will be ignored in favor of the `uv.toml` file:
- environments
Resolved 2 packages in 177ms
Audited 1 package in 0.59ms
I.e. there aren't any dependencies for Windows present in uv.lock, anymore.
The warning is also not entirely correct in this case, as uv apparently uses the setting in pyproject.toml.
The same warning is shown, when the environments setting is only present in pyproject.toml, so it cannot really be ignored in favor of the uv.toml file, obviously.
Is this a bug or a mistake on my part?
Platform
Ubuntu 24.04.2 x86_64 (WSL)
Version
uv 0.8.3
Python version
Python 3.13.1
Summary
It seems that
environmentssetting inuv.tomlis ignored when writing uv.lock.MWE:
In an empty directory in a linux environment execute:
Output:
Compare to adding the same
environmentssetting to pyproject.tomlOutput:
I.e. there aren't any dependencies for Windows present in uv.lock, anymore.
The
warningis also not entirely correct in this case, asuvapparently uses the setting in pyproject.toml.The same warning is shown, when the
environmentssetting is only present in pyproject.toml, so it cannot really be ignored in favor of the uv.toml file, obviously.Is this a bug or a mistake on my part?
Platform
Ubuntu 24.04.2 x86_64 (WSL)
Version
uv 0.8.3
Python version
Python 3.13.1