Repository navigation
Fix fish prompt hook never skipping redundant activate calls - #528
Merged
Merged
Conversation
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) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In fish, the prompt hook ran
pyenv activate --quietbefore every prompt. The cache from #523 is supposed to skip that call when nothing has changed, but its fish version never matched.Cause
The fish hook compared the stored mtimes against a quoted string:
Fish does not run command substitution inside double quotes, so this compared
_PYENV_VH_MTIMESagainst the literal text(stat -L -f %m ...). The comparison was always false. The bash and zsh hooks use"$(stat ...)", which does run, so only fish was affected.Fix
Run
statinto a local list, then compare it quoted:_PYENV_VH_MTIMESis stored as a list from(stat ...). Quoting both lists joins them with spaces the same way, so they compare correctly with one or many paths.I avoided
"$(...)"for two reasons. It needs fish 3.4 or later, and it keeps newlines, so it wouldn't match the stored list. As before,statonly runs when$PWDis unchanged.Testing
test/init.bats"outputs fish-specific syntax" is updated for the new output. It fails against the old hook code.pyenvthat countsactivatecalls:cd .., then another prompt.python-versionin a parent, then another prompt.python-versionPYENV_VERSIONsetWith the fix, fish behaves like the bash and zsh hooks. It reruns
activateafter a directory change, a version file change, or aPYENV_VERSIONchange, and skips it otherwise. On my machine, each skipped call saves about 250–290 ms per prompt.🤖 Generated with Claude Code
Summary by cubic
Fixes the fish prompt hook so it no longer runs
pyenv activate --quietbefore every prompt, restoring the mtime-based deduplication that already worked for bash and zsh.Bug Fixes
_PYENV_VH_MTIMESagainst the literal text and never matched.statnow runs into a local list, and both lists are compared viastring join;statstill only runs when$PWDis unchanged.test/init.batsis synced to match the new hook output.Written for commit 701c84d. Summary will update on new commits.