Run uv sync --all-packages After Workspace Changes

lesson tools active tools/uv-sync-all-packages-after-changes.md View on GitHub

Run uv sync --all-packages After Workspace Changes

Rule

After modifying workspace structure (adding dependencies or creating new packages), run 'uv sync --all-packages' to install all workspace packages and make them importable.

Context

In uv workspaces, packages can exist in the workspace configuration but not be installed in the virtual environment. This creates a disconnect where the workspace knows about packages, but Python cannot import them at runtime.

Detection

Pattern

When workspace structure changes:

  1. Verify package installation: uv pip list | grep <package>
  2. If missing, run: uv sync --all-packages
  3. Confirm all workspace packages are installed
  4. Test imports work correctly
# Check if package is installed
uv pip list | grep <package-name>

# If missing, sync all packages
uv sync --all-packages

# Verify installation
python3 -c "import <package_name>; print('OK')"

Outcome

Related

Match Keywords

ModuleNotFoundError workspace package package not installed despite pyproject.toml uv workspace package missing cannot import workspace package after adding uv sync all packages after changes