Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shell activation for zsh #5795

Merged
merged 6 commits into from
Sep 6, 2022
Merged

Fix shell activation for zsh #5795

merged 6 commits into from
Sep 6, 2022

Conversation

codeinred
Copy link
Contributor

@codeinred codeinred commented Jun 7, 2022

Fix Shell Activation For ZSH

This PR resolves an issue wherein poetry will clear the PATH on zsh. The activation script contains a number of if statements of the following form:

    # ...
    if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
        PATH="$_OLD_VIRTUAL_PATH"
        export PATH
        unset _OLD_VIRTUAL_PATH
    fi

These constructs are valid in bash, although zsh fails to negate the conditional except when placed in emulation mode:

# Causes PATH to be cleared, leading to other issues
. /home/alecto/.cache/pypoetry/virtualenvs/poetry-E-aAiPjf-py3.10/bin/activate

When bash is used as an emulator to source the script, it functions correctly:

# Functions correctly
emulate bash -c '. /home/alecto/.cache/pypoetry/virtualenvs/poetry-E-aAiPjf-py3.10/bin/activate'

It's important to note that this doesn't place the entire shell into bash emulation mode; only the activate script is sourced as bash.

Any guidance on what tests should be added for this PR would be appreciated.

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants