title: Openshift [Errno 13] Permission denied
body: <p>I met an exact same problem with what this link says:<a href="https://stackoverflow.com/questions/25473492/pip-install-failed-in-openshift-the-error-info-is-permission-denied">pip install Failed in OpenShift, the error info is Permission Denied</a>. I encountered the error while I was deploying <code>django-oscar</code> to openshift. To simplify the issue I did a test by creating a new cartridge. Then access my openshift server via ssh to execute the next command: <code>pip install django-oscar</code>. It has a good beginning but a bad ending as followed code shows:</p>
  
  <pre><code>mrju@mrju:~/Documents/My_Project/My_Website/Oscar_Test$ rhc app create oscartest python-2.7
  RSA 1024 bit CA certificates are loaded due to old openssl compatibility
  Application Options
  -------------------
  Domain:     mrju
  Cartridges: python-2.7
  Gear Size:  default
  Scaling:    no
  
  Creating application 'oscartest' ... done
  
  
  Waiting for your DNS name to be available ... done
  
  Cloning into 'oscartest'...
  The authenticity of host 'oscartest-mrju.rhcloud.com (52.3.216.108)' can't be established.
  RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added 'oscartest-mrju.rhcloud.com,52.3.216.108' (RSA) to the list of known hosts.
  
  Your application 'oscartest' is now available.
  
  
  
  mrju@mrju:~/Documents/My_Project/My_Website/Oscar_Test$ ssh 5773c52c2d52710e5e00024a@oscartest-mrju.rhcloud.com
  
  
  
  *********************************************************************
  
  You are accessing a service that is for use only by authorized users.
  If you do not have authorization, discontinue use at once.
  Any use of the services is subject to the applicable terms of the
  agreement which can be found at:
  https://www.openshift.com/legal
  
  *********************************************************************
  
  Welcome to OpenShift shell
  
  This shell will assist you in managing OpenShift applications.
  
  !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  Shell access is quite powerful and it is possible for you to
  accidentally damage your application.  Proceed with care!
  If worse comes to worst, destroy your application with "rhc app delete"
  and recreate it
  !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  
  Type "help" for more info.
  
  
  [oscartest-mrju.rhcloud.com 5773c52c2d52710e5e00024a]\&gt; 
  
  [oscartest-mrju.rhcloud.com 5773c52c2d52710e5e00024a]\&gt; cd /var/lib/openshift/5773c52c2d52710e5e00024a/python//virtenv/
  [oscartest-mrju.rhcloud.com virtenv]\&gt; ls
  bin  include  lib  lib64  pip-selfcheck.json
  [oscartest-mrju.rhcloud.com virtenv]\&gt; source bin/activate
  (virtenv)[oscartest-mrju.rhcloud.com virtenv]\&gt; pip install django-oscar
  ***The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.***
  You are using pip version 7.1.0, however version 8.1.2 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
  Collecting django-oscar
    Downloading django_oscar-1.2.1-py2.py3-none-any.whl (5.6MB)
      100% |████████████████████████████████| 5.6MB 39kB/s 
  Collecting phonenumbers&lt;8.0.0,&gt;=6.3.0 (from django-oscar)
    Downloading phonenumbers-7.4.3.tar.gz (2.3MB)
      100% |████████████████████████████████| 2.3MB 81kB/s 
  Collecting factory-boy&lt;2.7,&gt;=2.4.1 (from django-oscar)
    Downloading factory_boy-2.6.1-py2.py3-none-any.whl
  Collecting purl&gt;=0.7 (from django-oscar)
    Downloading purl-1.3-py2.py3-none-any.whl
  Collecting mock&lt;2.0,&gt;=1.0.1 (from django-oscar)
    Downloading mock-1.3.0-py2.py3-none-any.whl (56kB)
      100% |████████████████████████████████| 57kB 3.7MB/s 
  Collecting django&lt;1.9,&gt;=1.7.8 (from django-oscar)
    Downloading Django-1.8.13-py2.py3-none-any.whl (6.2MB)
      100% |████████████████████████████████| 6.2MB 61kB/s 
  Collecting django-haystack&lt;2.5.0,&gt;=2.3.1 (from django-oscar)
    Downloading django_haystack-2.4.1-py2-none-any.whl (95kB)
      100% |████████████████████████████████| 98kB 3.9MB/s 
  Collecting django-treebeard&gt;=3.0 (from django-oscar)
    Downloading django-treebeard-4.0.1.tar.gz (93kB)
      100% |████████████████████████████████| 94kB 2.6MB/s 
  Collecting django-extra-views&lt;0.6.5,&gt;=0.2 (from django-oscar)
    Downloading django_extra_views-0.6.4-py27-none-any.whl
  Collecting pillow&gt;=1.7.8 (from django-oscar)
    Downloading Pillow-3.2.0.zip (10.5MB)
      100% |████████████████████████████████| 10.5MB 22kB/s 
  Collecting Unidecode&lt;0.05,&gt;=0.04.12 (from django-oscar)
    Downloading Unidecode-0.04.19.tar.gz (204kB)
      100% |████████████████████████████████| 204kB 1.4MB/s 
  Collecting sorl-thumbnail==12.3 (from django-oscar)
    Downloading sorl_thumbnail-12.3-py2.py3-none-any.whl (40kB)
      100% |████████████████████████████████| 40kB 4.2MB/s 
  Collecting django-tables2&lt;1.1,&gt;=1.0.4 (from django-oscar)
    Downloading django-tables2-1.0.7.tar.gz (966kB)
      100% |████████████████████████████████| 970kB 343kB/s 
  Collecting Babel&lt;3.0,&gt;=1.0 (from django-oscar)
    Downloading Babel-2.3.4-py2.py3-none-any.whl (7.1MB)
      100% |████████████████████████████████| 7.1MB 46kB/s 
  Collecting django-widget-tweaks&gt;=1.4.1 (from django-oscar)
    Downloading django_widget_tweaks-1.4.1-py2.py3-none-any.whl
  Collecting fake-factory&gt;=0.5.0 (from factory-boy&lt;2.7,&gt;=2.4.1-&gt;django-oscar)
    Downloading fake_factory-0.5.8-py2.py3-none-any.whl (505kB)
      100% |████████████████████████████████| 507kB 618kB/s 
  Requirement already satisfied (use --upgrade to upgrade): six in /opt/rh/python27/root/usr/lib/python2.7/site-packages (from purl&gt;=0.7-&gt;django-oscar)
  Collecting funcsigs (from mock&lt;2.0,&gt;=1.0.1-&gt;django-oscar)
    Downloading funcsigs-1.0.2-py2.py3-none-any.whl
  Collecting pbr&gt;=0.11 (from mock&lt;2.0,&gt;=1.0.1-&gt;django-oscar)
    Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB)
      100% |████████████████████████████████| 98kB 3.5MB/s 
  Collecting pytz&gt;=0a (from Babel&lt;3.0,&gt;=1.0-&gt;django-oscar)
    Downloading pytz-2016.4-py2.py3-none-any.whl (480kB)
      100% |████████████████████████████████| 483kB 404kB/s 
  Collecting python-dateutil&gt;=2.4 (from fake-factory&gt;=0.5.0-&gt;factory-boy&lt;2.7,&gt;=2.4.1-&gt;django-oscar)
    Downloading python_dateutil-2.5.3-py2.py3-none-any.whl (201kB)
      100% |████████████████████████████████| 204kB 1.1MB/s 
  Collecting ipaddress (from fake-factory&gt;=0.5.0-&gt;factory-boy&lt;2.7,&gt;=2.4.1-&gt;django-oscar)
    Downloading ipaddress-1.0.16-py27-none-any.whl
  Building wheels for collected packages: phonenumbers, django-treebeard, pillow, Unidecode, django-tables2
  Exception:
  Traceback (most recent call last):
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
      status = self.run(options, args)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/commands/install.py", line 293, in run
      wb.build(autobuilding=True)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/wheel.py", line 756, in build
      ensure_dir(output_dir)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/utils/__init__.py", line 70, in ensure_dir
      os.makedirs(path)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
      makedirs(head, mode)
    File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 157, in makedirs
      mkdir(name, mode)
  OSError: [Errno 13] Permission denied: '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache'
  
  (virtenv)[oscartest-mrju.rhcloud.com virtenv]\&gt; 
  </code></pre>
  
  <p>The prompt is very useful</p>
  
  <pre><code>The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
  You are using pip version 7.1.0, however version 8.1.2 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
  </code></pre>
  
  <p>However I don't know how to get the sudo's permission or how to use sudo's -H flag.</p>