Common issues with the shared .venv and how to resolve them.
error: Failed to resolve dependencies
Package A requires foo>=2.0
Package B requires foo<2.0
Two packages in the workspace have incompatible dependency requirements.
# List all dependencies
uv pip list | grep foo
# Check which packages depend on foo
uv pip show foo# packages/package-a/pyproject.toml
[project]
dependencies = [
"foo>=2.0,<3.0", # More specific range
]
# packages/package-b/pyproject.toml
[project]
dependencies = [
"foo>=2.0,<3.0", # Match the range
]uv sync --all-packages- Use compatible version ranges
- Test dependency changes across all packages
- Use
uv lockto verify resolution
Critical Edge Case: Package imports a module available in shared .venv but not declared in its own pyproject.toml.
# In packages/my-package/src/my_package/module.py
import requests # Works locally, fails in CI
# Error in CI:
ModuleNotFoundError: No module named 'requests'- Locally:
requestsis in shared.venv(installed by another package) - CI: Strict isolation (
uv sync --package my-package) only installs declared deps
1. Identify the undeclared import
# Check what's importing requests
grep -r "import requests" packages/my-package/src/2. Add to pyproject.toml
# packages/my-package/pyproject.toml
[project]
dependencies = [
"requests>=2.31.0",
]3. Test with strict isolation (like CI)
# Remove .venv to start fresh
rm -rf .venv
# Sync only this package
uv sync --package my-package
# Try to run/test
uv run --package my-package pytest- Always test with
uv sync --package <name>before pushing - CI uses strict isolation by default (catches this)
- Review imports when adding new code
ModuleNotFoundError: No module named 'ai_kit_core'Package not installed or workspace dependency not configured.
1. Check workspace dependency
# apps/cli/pyproject.toml
[project]
dependencies = [
"ai-kit-core",
]
[tool.uv.sources]
ai-kit-core = { workspace = true } # Required!2. Re-sync
uv sync --all-packages3. Verify installation
uv pip list | grep ai-kiterror: Package foo==2.0.0 conflicts with foo==1.5.0
Multiple packages pin different versions of the same dependency.
uv pip show foo# Bad
dependencies = ["foo==2.0.0"]
# Good
dependencies = ["foo>=2.0.0,<3.0.0"]uv lock --upgrade
uv sync- Use version ranges, not exact pins
- Keep dependencies up to date
- Test upgrades across all packages
- Import errors for installed packages
- Unexpected behavior
uv syncfails with strange errors
- Interrupted installation
- Manual file modifications
- Disk corruption
# Remove corrupted .venv
rm -rf .venv
# Recreate from scratch
uv sync --all-packages
# Verify
just testuv cache clean
uv sync --all-packagesdf -h .# Full cleanup
just clean
# Recreate everything
uv sync --all-packages
pnpm install
# Verify
just test- Don't manually modify
.venv/ - Ensure adequate disk space
- Use
uv syncfor all changes
error: Failed to build package
gcc: command not found
Python package with C extensions requires compilation tools.
macOS:
xcode-select --installLinux (Ubuntu/Debian):
sudo apt-get install python3-dev build-essentialLinux (Fedora/RHEL):
sudo dnf install python3-devel gccWindows:
- Install Visual Studio Build Tools
- Or use pre-built wheels
- Document system dependencies in README
- Use packages with pre-built wheels when possible
- Test on target platforms
# Works on macOS/Linux, fails on Windows
path = "src/module.py"Hard-coded path separators.
# Use pathlib
from pathlib import Path
path = Path("src") / "module.py"Pre-commit hooks fail on Windows with CRLF line endings.
Git converts LF to CRLF on Windows.
# Configure git
git config --global core.autocrlf input
git config --global core.eol lf
# Fix existing files
uv run pre-commit run --all-filesWhen encountering .venv issues:
-
Check installation
uv pip list
-
Verify package location
uv pip show <package-name>
-
Test strict isolation
uv sync --package <package-name>
-
Check for conflicts
uv pip check
-
Recreate if needed
rm -rf .venv uv sync --all-packages
- ✅ Use version ranges in dependencies
- ✅ Declare all imports in pyproject.toml
- ✅ Test with strict isolation before pushing
- ✅ Keep dependencies up to date
- ✅ Use
uv syncfor all changes
- ❌ Manually modify .venv/
- ❌ Pin exact versions unless necessary
- ❌ Import without declaring
- ❌ Assume local = CI
- ❌ Ignore import errors