virtualenv fails with long paths #343

Open
elopio opened this Issue Oct 15, 2012 · 5 comments

5 participants

@elopio

This was reported on Launchpad by Michael Williamson: https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/1000778

Trying to run virtualenv inside a directory with a long path causes virtualenv to fail to install pip:

~/a1234567890/b1234567890/c1234567890/d1234567890/e1234567890/f1234567890/g1234567890/h1234567890$ virtualenv virtualenv
New python executable in virtualenv/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...
Error [Errno 13] Permission denied while executing command /home/mwilliamson/a1...env/bin/easy_install /usr/share/python-virtualenv/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in
virtualenv.main()
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
never_download=options.never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1054, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 643, in install_pip
filter_stdout=_filter_setup)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 976, in call_subprocess
cwd=cwd, env=env)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init

errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

@g2p

In the changelog for 1.7.2 (2012-06-22):

Restored ability to create a virtualenv with a path longer than 78 characters, without breaking creation of virtualenvs with non-ASCII paths. Thanks, Bradley Ayers.

I can confirm that this is broken in the Debian/Ubuntu package, and that it works with the development version.

@altryne

guys any progress on this?

@pfmoore
Python Packaging Authority member

Not that I know of. Can you confirm that it is still an issue with the latest virtualenv? Better still, if you can identify what is wrong that would be great - at a quick glance it looks like it may be an easy_install issue, which means that on the one hand it may no longer exist (we shouldn't be using easy_install any more), and on the other, if it does, reproducing it using just easy_install would help a lot.

@tardyp

The problem is because on linux kernel, the shebang path is limited to 127 bytes.

http://lxr.free-electrons.com/source/include/uapi/linux/binfmts.h#L18
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/binfmt_script.c?id=HEAD#n22

virtualenv creates a pip executable like:

#!/home/foo/a1234567890/b1234567890/c1234567890/d1234567890/e1234567890/f1234567890/g1234567890/h1234567890/virtualenv/bin/python2.7
# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

linux truncates the path to python2.7 to 127 bytes, and the try to execute that.

@tardyp

workaround is to make the virtualenv relocatable.

wheelhouse/virtualenv.py -p python2.7 out/virtualenv

wheelhouse/virtualenv.py --relocatable out/virtualenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment