From 1f1f5df2baa0262589d0ee35150836c269c406b7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 14:18:33 +0000 Subject: [PATCH] fix(poetry plugin): activate the in-project virtualenv so scripts land on PATH Since Poetry 2.0.0 removed the bundled `poetry shell` command, the poetry plugin relies on `poetry env use` (in initHook.sh) to point Poetry at the Devbox-provided Python. That selects the virtualenv but never activates it, so console scripts and entry points installed by `poetry install` live in `/.venv/bin` and are not on the Devbox shell's PATH. Users are forced to prefix everything with `poetry run`. The plugin already sets POETRY_VIRTUALENVS_IN_PROJECT=true, so the virtualenv is always created at `/.venv`. Activate it from the init_hook (which runs in the sourced shellrc context, unlike the executed initHook.sh) by exporting VIRTUAL_ENV and prepending its `bin` to PATH once the directory exists. Plugin init hooks run before the user's hooks, and `poetry env use` creates `.venv`, so the guard passes by the time the user's `poetry install` populates `.venv/bin`. The path templates are env-var based and fully double-quoted, so project directories containing spaces are handled correctly. Bump the plugin version so existing environments pick up the new hook. Fixes #2676 --- plugins/poetry.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/poetry.json b/plugins/poetry.json index a4da8e39675..bed0d139dd6 100644 --- a/plugins/poetry.json +++ b/plugins/poetry.json @@ -1,6 +1,6 @@ { "name": "poetry", - "version": "0.0.5", + "version": "0.0.6", "description": "This plugin automatically configures poetry to use the version of python installed in your Devbox shell, instead of the Python version that it is bundled with. The pyproject.toml location can be configured by setting DEVBOX_PYPROJECT_DIR (defaults to the devbox.json's directory).", "env": { "DEVBOX_DEFAULT_PYPROJECT_DIR": "{{ .DevboxProjectDir }}", @@ -13,7 +13,8 @@ }, "shell": { "init_hook": [ - "\"{{ .Virtenv }}/bin/initHook.sh\"" + "\"{{ .Virtenv }}/bin/initHook.sh\"", + "if [ -d \"${DEVBOX_PYPROJECT_DIR:-$DEVBOX_DEFAULT_PYPROJECT_DIR}/.venv\" ]; then export VIRTUAL_ENV=\"${DEVBOX_PYPROJECT_DIR:-$DEVBOX_DEFAULT_PYPROJECT_DIR}/.venv\"; export PATH=\"$VIRTUAL_ENV/bin:$PATH\"; fi" ] } }