Repository navigation
Description
Summary
When the cache directory path contains a space, uv run --with <pkg> <entrypoint> starts the entry point with the interpreter of the cached --with environment (archive-v0/...). That interpreter sees neither the project's packages nor the other --with overlay. Without a space in the cache path, the entry point runs in the ephemeral environment and sees the project's packages.
The ephemeral environment's copy of the entry point starts with a plain shebang, #!/…/cache with space/builds-v0/.tmpXXXX/bin/python. The kernel splits that line at the space, so execve fails with ENOENT. uv run then appears to try the next PATH entry (as execvp does), which is the cached --with environment's own launcher. That launcher uses the /bin/sh form and runs its own Python. This cause is inferred from the shebang and the observed prefix. I did not read uv's source.
This looks related to #22323, which has the same symptom (uv run --with packages invisible to an entry point) but a different trigger (the shebang of the project's launcher is the /bin/sh form). It differs here: the project's scripts are not involved, and the plain shebang that uv writes for the copied launcher is the one that breaks. I could not tell whether #22909 also covers this case.
Reproduction
Needs only uv and network access. The script is self-contained:
d=$(mktemp -d) && cd "$d"
mkdir -p probe/probe
cat > probe/pyproject.toml <<'EOF'
[project]
name = "probe"
version = "1.0"
scripts = { probe = "probe:main" }
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
EOF
cat > probe/probe/__init__.py <<'EOF'
import sys
def main():
print("prefix:", sys.prefix)
try:
import six
print("six: found")
except ImportError:
print("six: ImportError")
EOF
mkdir app && cd app
uv init --bare --name app -q
uv add -q six
for cache in "$d/cache" "$d/cache with space"; do
echo "UV_CACHE_DIR=$cache"
UV_CACHE_DIR="$cache" uv run --with ../probe -- probe
doneActual
UV_CACHE_DIR=/tmp/tmp.T3ukybR9Rx/cache
prefix: /tmp/tmp.T3ukybR9Rx/cache/builds-v0/.tmpNrqk8Q
six: found
UV_CACHE_DIR=/tmp/tmp.T3ukybR9Rx/cache with space
prefix: /tmp/tmp.T3ukybR9Rx/cache with space/archive-v0/Yx_1fUTJR-EKD37L
six: ImportError
Showing the launcher that uv run puts on PATH (uv run --with ../probe -- sh -c 'head -1 "$(command -v probe)"'):
#!/tmp/.../cache with space/builds-v0/.tmpMG1w7o/bin/python
The same shebang breaks outside uv: a script whose first line is #!/path with space/bin/python fails with required file not found.
Expected
Both runs print the ephemeral prefix under builds-v0 and six: found. The launcher that uv writes into the ephemeral environment should use the /bin/sh form when the interpreter path contains a space, as uv already does for a path over 127 bytes and for the cached environment's launchers.
Notes
python -c 'import six'under the sameuv run --with ../probeworks. Only entry points break.- Versions: uv 0.13.9 (latest on PyPI today), and also 0.13.6 and 0.11.32. All on Linux x86_64, CPython 3.13.
- I did not test macOS.
- Workaround: put the cache at a path without a space, or run
python -m <module>instead of the entry point.
Platform
Linux x86_64 (Linux 6.18)
Version
uv 0.13.9
Python version
CPython 3.13
Activity
abhi478jeetur-rgb commentedon Nov 19, 2026