Getting warning file permission with root user

What does this warning mean? I got it when executing following command using root at amazon ec2 Ubuntu 14.04 LTS instance:

$ pip install https://github.com/troeger/opensubmit/archive/0.6.2.tar.gz
The directory '/home/ubuntu/.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.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Well, your question partly has an answer in the quote:

You are using sudo to gain root permissions, but the way you are using sudo does not adjust the value of $HOME, so pip tries to install into the pip directory of the user who invoked sudo.

This might cause problems if the actual user would want to remove or change the installed modules, therefore the warning.

To avoid the warning and unless you don’t have to, use pip without root/sudo or invoke sudo as sudo -H which will set $HOME to the user you are changing to, in this case /root.

Solution 2

This message hints at the fact that you might have executed pip earlier using sudo for the then-issued command.

For example

sudo pip install https://github.com/troeger/opensubmit/archive/0.6.2.tar.gz

Per default, sudo does not change the environment variable HOME and therefore sudo env | grep HOME is printing HOME=/home/username. Adding -H to the sudo command changes this behaviour and it prints HOME=/root.

To solve your problem you should make sure every folder in this path /home/ubuntu/.cache/pip/http (except / and /home) is owned by ubuntu:

sudo -H chown -R ubuntu: /home/ubuntu/.cache

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply