浏览代码

fix(poetry-env): activate only if env exists (#12301)

Zikoeng Xi 1 月之前
父节点
当前提交
a168efe73e
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      plugins/poetry-env/poetry-env.plugin.zsh

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

@@ -14,10 +14,10 @@ _togglePoetryShell() {
   # activate the environment if pyproject.toml exists
   if [[ "$poetry_active" != 1 ]]; then
     if [[ -f "$PWD/pyproject.toml" ]]; then
-      if grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
+      if grep -q 'tool.poetry' "$PWD/pyproject.toml" && venv_dir=$(poetry env info --path); then
         export poetry_active=1
         export poetry_dir="$PWD"
-        source "$(poetry env info --path)/bin/activate"
+        source "${venv_dir}/bin/activate"
       fi
     fi
   fi