rehash: Do not execute conda-specific code if conda is not installed #3151
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.
Make sure you have checked all steps below.
Prerequisite
Description
I was doing some debugging with PYENV_DEBUG=1 and noticed that a lot of
work was being done in conda.bash, even though I have not installed any
conda versions like
mambaforge
.The solution is pretty simple, put all the code inside an if-block.
This aligns with what @varikin found in his pull request #3037
Additionally, I have refactored the code slightly for readability
(created function
build_conda_exclusion_list
), and added commentswhich should make it easier to understand what's going on.
In a later commit, I also did some slight performance improvements to
pyenv.d/rehash/conda.bash
.This PR simplifies debugging and should slightly reduce the execution time of
And by extension, the execution time of:
will be reduced slightly, especially if conda is not installed.
(NOTE: I am finding that it should be completely unnecessary to do a rehash upon init. I recommend using
pyenv init --no-rehash -
and would advocate for having --no-rehash as default option. Reason being that we have automatic rehash when installing/uninstalling python versions, and when doingpip
install/uninstall, and thus it all goes automatically.)Tests
No tests added