You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uv run --with packages invisible to project entrypoints when the venv path forces the /bin/sh shebang wrapper #22323
uv run --with <req> <entrypoint> stops seeing the --with packages when the project venv's path is long. A >127-byte shebang is enough.
In that case format_shebang (crates/uv-install-wheel/src/wheel.rs) writes the launcher as an absolute /bin/sh wrapper (#!/bin/sh / '''exec' '/abs/.venv/bin/python' "$0" "$@").
copy_entrypoint (crates/uv-project-commands/src/run.rs) only recognises the relocatable/bin/sh form and a bare #!<python> line, so it skips this form. The trace shows: Skipping copy of entrypoint .venv/bin/pytest: does not start with expected shebang.
The base launcher then runs the base interpreter, and the ephemeral --with environment is invisible to it.
The same project at a short path works. The bug shows up only at long paths, e.g. deep git worktrees or CI workspaces.
Reproduction
d="$TMPDIR/$(python3 -c 'print("a"*200)')/proj"# any path giving a >127-byte shebang
mkdir -p "$d"&&cd"$d"
uv init -q --bare --name repro
uv add -q pytest
printf'def test_x():\n import six\n'> test_x.py
head -1 .venv/bin/pytest # -> #!/bin/sh
uv run --with six pytest -q test_x.py # -> ModuleNotFoundError: No module named 'six'
uv run --with six python -m pytest -q test_x.py # -> 1 passed (workaround)
Run the same steps under a short directory (shebang ≤127 bytes) and uv run --with six pytest passes.
Expected
copy_entrypoint should also accept the absolute /bin/sh wrapper that uv itself writes for long paths, and rewrite it to point at the ephemeral interpreter.
Platform / version
macOS aarch64 (Darwin 27.0.0); uv 0.11.32 and 0.12.17 (same behaviour).
I read the code on main @ c0110fc, and copy_entrypoint still matches only the two forms above.
I was able to reproduce this issue on Linux, with uv release version 0.12.17 and with main at commit e8c3128.
Alongside this issue happening when the shebang is longer than 127 bytes, this same bug also occurs on shebang paths that have a space in them.
d="/tmp/my proj"
mkdir -p "$d"&&cd"$d"
uv init -q --bare --name repro
uv add -q pytest
printf'def test_x():\n import six\n'> test_x.py
uv run --with six pytest -q test_x.py # -> error saying no module named 'six'
By running this example and taking the first two lines of the launcher file for pytest, which start with the /bin/sh wrapper as seen below, we can see that the same issue is happening, where python launchers don't start with the expected shebang.
$ head -2 .venv/bin/pytest
#!/bin/sh'''exec''/tmp/my proj/.venv/bin/python'"$0""$@"
$ RUST_LOG=uv=trace uv run --with six pytest -q test_x.py 2>&1| grep "expected shebang"
TRACE Skipping copy of entrypoint `.venv/bin/py.test`: does not start with expected shebang
TRACE Skipping copy of entrypoint `.venv/bin/pytest`: does not start with expected shebang
TRACE Skipping copy of entrypoint `.venv/bin/pygmentize`: does not start with expected shebang
Thereby, causing the issue that module six cannot be found
format_shebang ends up choosing the /bin/sh wrapper when the shebang is longer than 127 bytes, has a space, or the venv is relocatable
"Skipping copy of entrypoint `{}`: does not start with expected shebang",
source.user_display()
);
One way to fix this is to have copy_entrypoint also accept the absolute /bin/sh wrapper (which is the exact text format_shebang would produce for the project's Python), strip it, and then write the launcher pointing at the --with environment's Python
I traced this to a mismatch between the launcher format generated by format_shebang and the formats accepted by copy_entrypoint.
crates/uv-install-wheel/src/wheel.rs emits an absolute /bin/sh wrapper when the executable path exceeds the shebang length limit or contains spaces. However, crates/uv-project-commands/src/run.rs only recognizes the relocatable /bin/sh wrapper and direct Python shebang forms. The generated absolute wrapper is therefore skipped, leaving the entrypoint to run outside the ephemeral --with environment.
A targeted fix would be to recognize the absolute wrapper format that format_shebang generates, extract its original launcher payload, and rewrite it to invoke the ephemeral environment's interpreter. I would match the expected wrapper structure rather than treating arbitrary /bin/sh scripts as Python entrypoints.
Regression tests should cover:
A normal Python shebang.
The existing relocatable /bin/sh wrapper.
An absolute /bin/sh wrapper caused by a long executable path.
An absolute wrapper caused by spaces in the path.
A non-Python shell script that must continue to be skipped.
An end-to-end uv run --with six pytest case proving the extra dependency is importable through the copied entrypoint.
The reported uv run --with six python -m pytest workaround is also a useful control case: it should continue to pass independently of the entrypoint-copying path.
Activity
kidskoding commentedon Oct 9, 2026
Hi!
I was able to reproduce this issue on Linux, with uv release version 0.12.17 and with main at commit e8c3128.
Alongside this issue happening when the shebang is longer than 127 bytes, this same bug also occurs on shebang paths that have a space in them.
By running this example and taking the first two lines of the launcher file for pytest, which start with the
/bin/shwrapper as seen below, we can see that the same issue is happening, where python launchers don't start with the expected shebang.Thereby, causing the issue that module
sixcannot be foundformat_shebangends up choosing the/bin/shwrapper when the shebang is longer than 127 bytes, has a space, or the venv is relocatableuv/crates/uv-install-wheel/src/wheel.rs
Lines 123 to 134 in e8c3128
copy_entrypointonly accepts the relocatable/bin/shwrapper or a plain#!<python>line, and then skips everything elseuv/crates/uv-project-commands/src/run.rs
Lines 2083 to 2105 in e8c3128
One way to fix this is to have
copy_entrypointalso accept the absolute/bin/shwrapper (which is the exact textformat_shebangwould produce for the project's Python), strip it, and then write the launcher pointing at the--withenvironment's PythonWould be happy to open a PR if that is welcome!
PrithwishDas101 commentedon Oct 18, 2026
I traced this to a mismatch between the launcher format generated by
format_shebangand the formats accepted bycopy_entrypoint.crates/uv-install-wheel/src/wheel.rsemits an absolute/bin/shwrapper when the executable path exceeds the shebang length limit or contains spaces. However,crates/uv-project-commands/src/run.rsonly recognizes the relocatable/bin/shwrapper and direct Python shebang forms. The generated absolute wrapper is therefore skipped, leaving the entrypoint to run outside the ephemeral--withenvironment.A targeted fix would be to recognize the absolute wrapper format that
format_shebanggenerates, extract its original launcher payload, and rewrite it to invoke the ephemeral environment's interpreter. I would match the expected wrapper structure rather than treating arbitrary/bin/shscripts as Python entrypoints.Regression tests should cover:
/bin/shwrapper./bin/shwrapper caused by a long executable path.uv run --with six pytestcase proving the extra dependency is importable through the copied entrypoint.The reported
uv run --with six python -m pytestworkaround is also a useful control case: it should continue to pass independently of the entrypoint-copying path.