Skip to content

Conversation

@native-api
Copy link
Member

Make sure you have checked all steps below.

Prerequisite

  • Please consider implementing the feature as a hook script or plugin as a first step.
    • pyenv has some powerful support for plugins and hook scripts. Please refer to Authoring plugins for details and try to implement it as a plugin if possible.
  • Please consider contributing the patch upstream to rbenv, since we have borrowed most of the code from that project.
    • We occasionally import the changes from rbenv. In general, you can expect changes made in rbenv will be imported to pyenv too, eventually.
    • Generally speaking, we prefer not to make changes in the core in order to keep compatibility with rbenv.
  • My PR addresses the following pyenv issue (if any)

Description

  • Here are some details about my PR
    pyenv-which used to only delete $PYENV_ROOT/shims from PATH when looking for an executable for the system version.
    This PR makes a shim indicate to pyenv-exec that it's been called from an unusual location, ultimately causing pyenv-which to delete it from PATH as well.
    Moreover, pyenv-exec compiles a list envvar for "fake" executables for a given command, which prevents a loop even if there's more than one shim on PATH.

Tests

  • My PR adds the following unit tests (if any)
    Tests for the new functionality

@native-api native-api requested review from a team as code owners December 19, 2025 13:11
@native-api native-api marked this pull request as draft December 19, 2025 13:11
@native-api native-api force-pushed the fix_inf_loop_shim_different_location branch from c061c7b to 624b33f Compare December 20, 2025 05:34
@native-api native-api marked this pull request as ready for review December 20, 2025 05:46
@native-api native-api force-pushed the fix_inf_loop_shim_different_location branch 3 times, most recently from 3d8b6f7 to 512ebc3 Compare December 20, 2025 06:40
@native-api native-api force-pushed the fix_inf_loop_shim_different_location branch from 77ba93e to 6113214 Compare December 20, 2025 08:05
@native-api native-api merged commit 22993a2 into pyenv:master Dec 20, 2025
19 checks passed
@native-api native-api changed the title Fix an infinite loop if a shim is symlinked to and called from a different location Fix an infinite loop if a shim is symlinked to and called from a different location with "system" version active Dec 20, 2025
@native-api native-api deleted the fix_inf_loop_shim_different_location branch January 14, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite loop when system python is a link to a pyenv shim

1 participant