Skip to content

uv sync removes base dependencies when switching extras (at least impacts typer/typer-slim) #17645

@pimlock

Description

@pimlock

Summary

Summary

When switching extras with uv sync (or uv tool install), packages that provide conflicting files (like typer and typer-slim) can corrupt the venv. Installing typer-slim overwrites typer's files, and uninstalling typer-slim deletes them—leaving uv's metadata incorrectly showing typer as installed while the actual files are gone.

Reproduction

I created a repo with the repro example: https://github.com/pimlock/uv-bug-repro

When this happened in my workflow, the dependency tree was more complex, the base package depended on typer and one of deps defined in extra had typer-slim as a dep few levels deep.

Here's the verbose output when running all the commands with the spot where the "issue" happens being highlighted

Commands:

git clone https://github.com/pimlock/uv-bug-repro
cd uv-bug-repro

uv sync                     # ✓ works
uv sync --extra extra1      # ✓ works
uv sync --extra extra2      # ✗ ModuleNotFoundError: No module named 'typer'

The package has:

  • Base dependency: typer>=0.20.0
  • extra1: typer-slim>=0.20.0
  • extra2: rich>=13.0.0 (note: what deps extra2 has is irrelevant for this issue)

What happens

  1. uv sync installs typer (which doesn't depend on typer-slim)
  2. uv sync --extra extra1 adds typer-slim
  3. uv sync --extra extra2 removes typer-slim, but because they "contribute" the same module in venv, the typer's files get removed as well.

This issue is likely caused by how typer and typer-slim are set up (i.e. typer doesn't depend on typer-slim), but it may be potentially causing similar issues with other packages (AFAIK pydantic uses the -slim pattern, but in a different way).

  • typer requires: click, typing-extensions, shellingham, rich
  • typer-slim requires: click, typing-extensions

They conflict because they both install files to the same typer/ directory. So here's what's happening:

  1. Step 1: typer installed → typer/ directory created
  2. Step 2: typer-slim installed → overwrites typer/ directory
  3. Step 3: typer-slim uninstalled → deletes typer/ directory

Expected

Base dependency typer>=0.20.0 should always be installed regardless of which extras are selected.

Workaround

uv sync --extra extra2 --reinstall works correctly.

Platform

Darwin 25.2.0 arm64

Version

uv 0.9.26 (ee4f003 2026-01-15)

Python version

CPython 3.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThe problem is with another package or dependency (not uv)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions