Skip to content

Commit 52c830c

Browse files
fix(poetry-env): handle Poetry returning "." for venv path (ohmyzsh#13183)
1 parent 8c3cce9 commit 52c830c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

plugins/poetry-env/poetry-env.plugin.zsh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ _togglePoetryShell() {
1515
# Activate the environment if in a Poetry directory and no environment is currently active
1616
if [[ $in_poetry_dir -eq 1 ]] && [[ $poetry_active -ne 1 ]]; then
1717
venv_dir=$(poetry env info --path 2>/dev/null)
18-
if [[ -n "$venv_dir" ]]; then
18+
# Handle case where poetry returns "." for in-project virtual environments
19+
if [[ "$venv_dir" == "." ]]; then
20+
venv_dir="$PWD/.venv"
21+
fi
22+
# Only proceed if venv_dir is set and the activate script exists
23+
if [[ -n "$venv_dir" && -f "${venv_dir}/bin/activate" ]]; then
1924
export poetry_active=1
2025
export poetry_dir="$PWD"
2126
source "${venv_dir}/bin/activate"

0 commit comments

Comments
 (0)