virtualenv: Long env path names cause weird errors after activiting virtual environment

After creating a virtualenv in the path

/home/harald/git-repos/sandbox/stackoverflow/41454203-how-do-you-import-the-library-being-tested-when-running-a-nosetest/env

I could not run the env’s pip,

nosetest/env$ ./bin/pip
bash: ./bin/pip: /home/harald/git-repos/sandbox/stackoverflow/41454203-how-do-you-import-the-l: bad interpreter: Permission denied

and running just pip gives me the system’s pip, with all of its packages.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

I’ve updated distlib to handle long paths and paths with spaces. I didn’t use Harald Nordgren’s patch directly (it had some problems - e.g. no tests) but the approach is the same - using ‘/bin/sh’ as the executable. pip / virtualenv maintainers might want to test after locally vendoring the current version of the distlib repository.

Not virtualenv’s fault. Shebangs have length limits, see http://www.in-ulm.de/~mascheck/various/shebang/.

This is basically a duplicate of #994 - virtualenv are broken with fragile kernel shebang parsing.