Skip to content

Conversation

@efiop
Copy link
Contributor

@efiop efiop commented Sep 23, 2019

Unlike PyInstaller, pyenv doesn't leave backups of original env vars
when it modifies them. If we look into the shim, pyenv and pyenv-exec,
we can figure out that the PATH is modified like this:

PATH=$PYENV_BIN_PATH:${bin_path}:${plugin_bin}:$PATH

where

PYENV_BIN_PATH - starts with $PYENV_ROOT, see pyenv-exec source code.
bin_path - might not start with $PYENV_ROOT as it runs realpath on
    it, see pyenv source code.
plugin_bin - might contain more than 1 entry, which start with
    $PYENV_ROOT, see pyenv source code.

So having this, we can make a rightful assumption about what parts of the PATH
we need to remove in order to get the original PATH.

Fixes #2506

  • Have you followed the guidelines in our
    Contributing document?

  • Does your PR affect documented changes or does it add new functionality
    that should be documented? If yes, have you created a PR for
    dvc.org documenting it or at
    least opened an issue for it? If so, please add a link to it.


@efiop efiop changed the title dvc: remove PATH prefixes appended by pyenv [WIP] dvc: remove PATH prefixes appended by pyenv Sep 23, 2019
Unlike PyInstaller, pyenv doesn't leave backups of original env vars
when it modifies them. If we look into the shim, pyenv and pyenv-exec,
we can figure out that the PATH is modified like this:

    PATH=$PYENV_BIN_PATH:${bin_path}:${plugin_bin}:$PATH

where

    PYENV_BIN_PATH - starts with $PYENV_ROOT, see pyenv-exec source code.
    bin_path - might not start with $PYENV_ROOT as it runs realpath on
        it, see pyenv source code.
    plugin_bin - might contain more than 1 entry, which start with
        $PYENV_ROOT, see pyenv source code.

So having this, we can make a rightful assumption about what parts of the PATH
we need to remove in order to get the original PATH.

Fixes treeverse#2506
@efiop efiop changed the title [WIP] dvc: remove PATH prefixes appended by pyenv dvc: remove PATH prefixes appended by pyenv Sep 23, 2019
@efiop efiop requested review from a user, Suor and pared September 23, 2019 06:17
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.

dvc run unexpectedly modifies PATH before running commands

2 participants