Skip to content

fix(presets): clear inherited VIRTUAL_ENV before building the run venv - #349

Open
smolpaws wants to merge 1 commit into
OpenHands:mainfrom
smolpaws:fix/setup-venv-inherited-virtualenv
Open

fix(presets): clear inherited VIRTUAL_ENV before building the run venv#349
smolpaws wants to merge 1 commit into
OpenHands:mainfrom
smolpaws:fix/setup-venv-inherited-virtualenv

Conversation

@smolpaws

Copy link
Copy Markdown

What

Clear an inherited VIRTUAL_ENV before building the per-run virtualenv in both preset setup.sh files (prompt and plugin).

Why

In local agent-server mode, when the agent-server is launched via uv run, its child bash shells inherit VIRTUAL_ENV pointing at the agent-server's own venv. The preset setup.sh then does:

uv venv .venv --python '>=3.12' --quiet
uv pip install --quiet "openhands-sdk==${SDK_VERSION}" ...

uv pip install installs into $VIRTUAL_ENV when it's set, so the SDK lands in the inherited venv, not the freshly-created .venv. The run's .venv stays empty, setup.sh still prints [setup] Done, and main.py then fails:

ModuleNotFoundError: No module named 'openhands'

This makes local-agent-server automation runs fail on any deployment whose agent-server runs under uv run.

Fix

unset VIRTUAL_ENV right before the uv venv / uv pip install calls, so uv targets the .venv created in the run's working directory. One line, both presets.

Verification

Reproduced on a self-hosted local-mode deployment: a bash command run through the agent-server printed VIRTUAL_ENV=/…/.venv; runs failed at import openhands with an empty run .venv. After clearing VIRTUAL_ENV, the same install populated the run .venv correctly and the automation completed end-to-end.

Fixes #348

When the local agent-server is launched via `uv run`, its child bash shells
inherit VIRTUAL_ENV. The preset setup.sh then runs `uv pip install` which
targets that inherited venv instead of the freshly-created .venv, leaving the
run venv empty; main.py fails with ModuleNotFoundError: No module named
'openhands' even though setup reports success.

Clear VIRTUAL_ENV before the uv venv/pip calls in both the prompt and plugin
presets so the SDK installs into the run's own .venv.

Fixes OpenHands#348

Co-authored-by: smolpaws <engel@enyst.org>
@github-actions github-actions Bot added the type: fix A bug fix label Aug 19, 2026
@all-hands-bot

Copy link
Copy Markdown
Contributor

👋 This PR needs a couple of things fixed before OpenHands can review it:

  • the PR description's HUMAN: section needs at least 20 characters describing what you tested, not just the template placeholder

Push an update once this is addressed and this check re-runs automatically.

This is an automated check - no AI was used to generate this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preset setup.sh installs SDK into inherited VIRTUAL_ENV, not the run venv → local-mode runs fail with ModuleNotFoundError

3 participants