From 1f1f5df2baa0262589d0ee35150836c269c406b7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 14:18:33 +0000 Subject: [PATCH 1/2] 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" ] } } From b6d4906bdf00417958e5d72640df7f92d53f25ce Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 15 Sep 2026 20:30:47 +0000 Subject: [PATCH 2/2] fix(poetry plugin): prepend venv bin via env for fish compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous approach inlined a POSIX `if [ -d … ]; then … fi` compound statement in the plugin's init_hook. That breaks the fish shell: fish sources the combined .hooks file natively (internal/devbox/shellrc_fish.tmpl), and fish has no `then`/`fi` keywords (its blocks close with `end`), so the unterminated `if` is a parse error that aborts the entire hooks file — not just poetry's activation — for any fish user with the poetry plugin. Prepend the in-project virtualenv's bin directory to PATH via the plugin's `env` field instead, matching the existing, shell-portable convention used by the nodejs and ruby plugins (e.g. nodejs `"PATH": "{{ .Virtenv }}/corepack-bin:$PATH"`). Devbox expands the value with os.Expand and emits it as a literal export, so it is applied uniformly across bash, zsh, and fish with no inline shell syntax. The path uses the {{ .DevboxProjectDir }} template (POETRY_VIRTUALENVS_IN_PROJECT is true, so the venv lives at /.venv); a not-yet-created dir on PATH is harmless and resolves once `poetry install` populates it. Fixes #2676 Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_012aiRPVpidRdyKDJiUQJhxN --- plugins/poetry.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/poetry.json b/plugins/poetry.json index bed0d139dd6..5b94cfe92ef 100644 --- a/plugins/poetry.json +++ b/plugins/poetry.json @@ -6,15 +6,15 @@ "DEVBOX_DEFAULT_PYPROJECT_DIR": "{{ .DevboxProjectDir }}", "POETRY_VIRTUALENVS_IN_PROJECT": "true", "POETRY_VIRTUALENVS_CREATE": "true", - "POETRY_VIRTUALENVS_PATH": "{{.Virtenv}}/.virtualenvs" + "POETRY_VIRTUALENVS_PATH": "{{.Virtenv}}/.virtualenvs", + "PATH": "{{ .DevboxProjectDir }}/.venv/bin:$PATH" }, "create_files": { "{{ .Virtenv }}/bin/initHook.sh": "poetry/initHook.sh" }, "shell": { "init_hook": [ - "\"{{ .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" + "\"{{ .Virtenv }}/bin/initHook.sh\"" ] } }