virtualenv: activate.sh fails if 'nounset' option is set

I get the following error when I try to activate a virtualenv.

$ source test-env/bin/activate
-bash: _OLD_VIRTUAL_PATH: unbound variable

This is happening because I’ve configured Bash to use the nounset option, which throws an error when accessing unset variables (see here)

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Workaround for now—

set -o nounset

[...]

set +o nounset
. ~/.env/bin/activate
set -o nounset

[...]

Actually, that’s a lame fix, since it requires rewriting all existential tests. It’s far easier to just add set -o nounset to the top of the script.