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

Error in activate script: _OLD_VIRTUAL_PYTHONHOME: unbound variable #4114

Closed
heartsucker opened this issue Nov 14, 2016 · 4 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@heartsucker
Copy link

  • Pip version: 9.0.1
  • Python version: 2.7.6
  • Operating System: Ubuntu 14.04

Full system details.

root@ubuntu:~# pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
root@ubuntu:~# python2.7 --version
Python 2.7.6
root@ubuntu:~# uname -a
Linux ubuntu 4.8.3-x86_64-linode76 #1 SMP Thu Oct 20 19:05:39 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu:~# pip3 --version
pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
root@ubuntu:~# python3 --version
Python 3.4.3

Description:

I have a Debian package that has a postinst script that create a virtual environment, activates it, then installs some packages.

What I've run:

$ dpkg -i <my-deb>
...
...
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
venv/bin/activate: line 13: _OLD_VIRTUAL_PYTHONHOME: unbound variable
@heartsucker
Copy link
Author

I found the problem. It was an errant set -u floating around somewhere. Since the script expects the shell to allow undefined variables, I would recommend adding a set +u to the top to ensure that nothing breaks in other environments.

@ssbarnea
Copy link
Contributor

ssbarnea commented Mar 7, 2017

This is closely related to pypa/virtualenv#150 and would have being avoided by using vate the virtual environment using a simple strict bash test.

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
source .venv/bin/activate

This would use the strict mode to test the activate script. My workaround line is endlessly growing PS1="${{PS1:-}}" _OLD_VIRTUAL_PATH="${{_OLD_VIRTUAL_PATH:-}}" _OLD_VIRTUAL_PYTHONHOME="${{_OLD_VIRTUAL_PYTHONHOME:-}}" source "$VENV/bin/activate" .... but now I get line 22: ZSH_VERSION: unbound variable....

@xavfernandez
Copy link
Member

Not sure how it is pip related ?

@dstufft
Copy link
Member

dstufft commented Mar 31, 2017

This looks to be a virtualenv issue and should be opened/discussed on the virtualenv tracker.

@dstufft dstufft closed this as completed Mar 31, 2017
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

4 participants