Skip to content
New issue

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

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

Already on GitHub? # to your account

pyenv activate <env> fails due to unbound variable when set -u is in effect #422

Closed
12 tasks done
ackalker opened this issue Jan 29, 2022 · 3 comments
Closed
12 tasks done

Comments

@ackalker
Copy link
Contributor

ackalker commented Jan 29, 2022

Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.

Prerequisite

  • Make sure your problem is not listed in the common build problems.
  • Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
  • Make sure you are not asking us to help solving your specific issue.
    • GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
  • Make sure your problem is not derived from packaging (e.g. Homebrew).
    • Please refer to the package documentation for the installation issues, etc.
  • Make sure your problem is not derived from other plugins.
    • This repository is maintaining the pyenv-virtualenv plugin only. Please refrain from reporting issues of other plugins here.

Description

  • Platform information (e.g. Ubuntu Linux 20.04): Void Linux (rolling release)
  • OS architecture (e.g. amd64): x86_64
  • pyenv version: pyenv 2.2.4-1
  • pyenv-virtualenv version: pyenv-virtualenv 1.1.5 (python -m venv)
  • Python version: Python 3.10.2
  • virtualenv version (if installed): n/a
  • Please attach the debug log of a faulty Pyenv invocation as a gist
    • If the problem happens in a Pyenv invocation, you can turn on debug logging by setting PYENV_DEBUG=1, e.g. env PYENV_DEBUG=1 pyenv install -v 3.6.4
    • If the problem happens outside of a Pyenv invocation, get the debug log like this:
      export PS4='+(${BASH_SOURCE:-}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
      set -x
      <reproduce the problem>
      set +x
      

Using Bash, when set -u is in effect, pyenv activate <env> fails with unbound variable errors. This happens both in interactive shells and shell scripts in which eval "$(pyenv init -)" is used.

EDIT: Cleaned-up gists are in the next comment.

@ackalker
Copy link
Contributor Author

ackalker commented Jan 29, 2022

Gist reproducing the problem in an interactive shell: here
Gist reproducing the problem in an interactive shell, with PYENV_DEBUG=1 set: here

@ackalker
Copy link
Contributor Author

ackalker commented Jan 29, 2022

Similar issues with set -u and unbound variables when activating virtualenvs were found and fixed in pypa/virtualenv#1029 and python/cpython#3804 .

@ackalker
Copy link
Contributor Author

@native-api
Please also look at my other PR #423, this fixes the case where a script with set -u but with PYENV_VIRTUALENV_DISABLE_PROMPT not set tries to activate a virtualenv. Sorry for splitting this up, I forgot to test this case on my side. I have now also fixed the Bats tests which were failing due to my change.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants