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
sudo as user (-u) causes virtualenv to throw permission error #535
Comments
+1 .. I am installing using the opscode python cookbook resources on a new Ubuntu 12.04 VM and this is the point where my install is failing as well. Was working prior to the latest virtualenv update. |
I'm not a Unix user, but if you do sudo like that, is your home directory set for the user you sudo to (i.e., is $HOME set - I think that's the key thing)? If not, this is probably caused by this distlib bug: https://bitbucket.org/pypa/distlib/issue/39/using-distlib-with-pip-fails-when-user-has You can check by doing |
That makes sense as there is this PR on the opscode python recipe for virtualenv: Which sets the $HOME directory whenever it is being used. Was working fine with all the older virtualenvs though. Just made the changes suggested in the (amended) PR above and it fixes the problem. |
Can you check the upgrade-pip-distlib branch and see if it solves this problem for you? |
I'm reproduced this issue and verified that the distlib in the upgrade-pip-distlib branch fixes this issue. So what we need to actually fix this issue is a new distlib release from @vsajip |
Okay. Before doing a release, I'd like to be sure that |
Ok @vsajip Hopefully soon :) we almost have everything taken care of for 1.11.1 and 1.5.1 and we'll want to start the RC process soon. |
Hey @vsajip Any ETA on distlib btw? We've cleaned up all the other issues and are now just waiting on a new distlib to fix this issue. |
I haven't yet heard from the OP of https://bitbucket.org/pypa/distlib/issue/39#comment-7649881 that his issue (analogous to this) has been resolved, but I plan on doing a |
Sounds good, thanks. |
Solved now in pip, the pip in virtualenv has been upgraded, and 1.11.1rc2 has been released. |
If you run
virtualenv env
as the user you want it to be owned by it works fine.
If you have to do
sudo -u myuser virtualenv it will create the folder and python links fine, but then pip seems to fail with
OSError: [Errno 13] Permission denied: '/root/.distlib'
Full stack is
New python executable in arctic_py/bin/python
Installing setuptools, pip...
Complete output from command /opt/pyenv/arctic_py/bin/python -c "import sys, pip; pip...ll"] + sys.argv[1:])" setuptools pip:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/init.py", line 11, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/vcs/subversion.py", line 4, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/index.py", line 16, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/wheel.py", line 23, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 15, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/_vendor/distlib/resources.py", line 105, in
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/_vendor/distlib/resources.py", line 40, in init
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/_vendor/distlib/util.py", line 602, in get_cache_base
File "/opt/pyenv/arctic_py/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/root/.distlib'
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in
load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 820, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 988, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 956, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 898, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /opt/pyenv/arctic_py/bin/python -c "import sys, pip; pip...ll"] + sys.argv[1:])" setuptools pip failed with error code 1
Works fine if you don't have to use sudo -u. Worked before latest virtualenv.
The text was updated successfully, but these errors were encountered: