From 820457bf2ceb004145340ad58c42872d27324b7d Mon Sep 17 00:00:00 2001 From: Ethan Leifer Date: Thu, 1 Oct 2026 12:46:57 -0400 Subject: [PATCH 1/3] Fix fish prompt hook never skipping redundant activate calls The fish hook compared _PYENV_VH_MTIMES against "(stat ...)". Inside double quotes fish does not run command substitution, so the comparison was against literal text and always failed. The hook then ran `pyenv activate --quiet` before every prompt instead of only when the directory or a version file changed. Run stat into a local list and compare it quoted, the same way _PYENV_VH_MTIMES is stored. stat still only runs when $PWD is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) --- bin/pyenv-virtualenv-init | 8 +++++--- test/init.bats | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 03feec7d..b781ebb1 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -132,9 +132,11 @@ EOS if test -n "\$PYENV_VERSION" return \$ret end - if test "\$PWD" = "\$_PYENV_VH_PWD" \\ - -a "(stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null)" = "\$_PYENV_VH_MTIMES" - return \$ret + if test "\$PWD" = "\$_PYENV_VH_PWD" + set -l mtimes (stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null) + if test "\$mtimes" = "\$_PYENV_VH_MTIMES" + return \$ret + end end end EOS diff --git a/test/init.bats b/test/init.bats index 11e3a1ba..c8557d2d 100644 --- a/test/init.bats +++ b/test/init.bats @@ -112,9 +112,11 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; if test -n "\$PYENV_VERSION" return \$ret end - if test "\$PWD" = "\$_PYENV_VH_PWD" \\ - -a "(stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null)" = "\$_PYENV_VH_MTIMES" - return \$ret + if test "\$PWD" = "\$_PYENV_VH_PWD" + set -l mtimes (stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null) + if test "\$mtimes" = "\$_PYENV_VH_MTIMES" + return \$ret + end end end if [ -n "\$VIRTUAL_ENV" ] From e2a49d5300b0f76033224f5a267731b256cfc064 Mon Sep 17 00:00:00 2001 From: native-api Date: Mon, 12 Oct 2026 20:49:27 +0300 Subject: [PATCH 2/3] Apply cubic suggestion for test/init.bats Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- test/init.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init.bats b/test/init.bats index c8557d2d..c6607325 100644 --- a/test/init.bats +++ b/test/init.bats @@ -114,7 +114,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; end if test "\$PWD" = "\$_PYENV_VH_PWD" set -l mtimes (stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null) - if test "\$mtimes" = "\$_PYENV_VH_MTIMES" + if test (string join " " $mtimes) = (string join " " $_PYENV_VH_MTIMES) return \$ret end end From 701c84d43617040dfcb2994211a5ce0c0c086b4c Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Mon, 12 Oct 2026 20:57:05 +0300 Subject: [PATCH 3/3] sync changes --- bin/pyenv-virtualenv-init | 2 +- test/init.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index b781ebb1..62956b12 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -134,7 +134,7 @@ EOS end if test "\$PWD" = "\$_PYENV_VH_PWD" set -l mtimes (stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null) - if test "\$mtimes" = "\$_PYENV_VH_MTIMES" + if test (string join " " \$mtimes) = (string join " " \$_PYENV_VH_MTIMES) return \$ret end end diff --git a/test/init.bats b/test/init.bats index c6607325..79cba6ba 100644 --- a/test/init.bats +++ b/test/init.bats @@ -114,7 +114,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; end if test "\$PWD" = "\$_PYENV_VH_PWD" set -l mtimes (stat ${_stat_fmt} \$_PYENV_VH_PATHS 2>/dev/null) - if test (string join " " $mtimes) = (string join " " $_PYENV_VH_MTIMES) + if test (string join " " \$mtimes) = (string join " " \$_PYENV_VH_MTIMES) return \$ret end end