Fix PET failures with pyenv shims by detecting and skipping them #255
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.
This PR resolves a significant performance issue where PET fails when encountering pyenv shims in the PATH environment variable.
Problem
When pyenv shims are present in PATH, PET attempts to execute them directly to gather Python environment information. However, pyenv shims are shell scripts that require proper environment context to function correctly. When executed directly by PET, they:
Python Execution for "/path/.pyenv/shims/python3.10" produced an output "" without a separator
Solution
Added pyenv shim detection logic in
pet-python-utils/src/env.rs
that identifies and skips pyenv shims before attempting to execute them:Detection Methods
/.pyenv/shims/
PYENV_ROOT
,pyenv
,exec
)Implementation Details
is_pyenv_shim()
function with comprehensive detection logicget_interpreter_details()
to skip detected shims early in the processTesting
pyenv_shim_test.rs
covering both detection methodsImpact
The fix maintains the principle mentioned in the codebase documentation: "Avoid spawning processes" when they won't provide useful information.
Fixes #238.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.