You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to run sudo -u pi /home/pi/oprint/bin/pip install cryptography as part of OctoPi's build, which runs inside a chroot script.
However it seems that this command somehow managed to see beyond the chroot and resolves the cache folder to be /home/pi/.cache/pip. Where guy is the user outside my chroot. I am not sure even how it knows that. But it does, and it breaks the installation.
This happens only in the Ubuntu chroot, not in the Debian Jessie one.
Adding the -H option to the sudo fixes the install, and is the current workaround i am using, but still the cache folder is shows up in this line options.cache_dir variable (if I stick a print line I can see that options.cache_dir is pointing out of the chroot, even with -H flag on.
Two questions:
Is there a way to fix this without using the -H option?
Where is the options.cache_dir variable resolved in pip? Is there a way to fix it?
What I've run:
sudo -u pi /home/pi/oprint/bin/pip install cryptography
log:
+ sudo -u pi /home/pi/oprint/bin/pip install cryptography
The directory '/home/guy/.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/guy/.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.
Collecting cryptography
Exception:
Traceback (most recent call last):
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/commands/install.py", line 299, in run
requirement_set.prepare_files(finder)
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/req/req_set.py", line 370, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/req/req_set.py", line 522, in _prepare_file
finder, self.upgrade, require_hashes)
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/req/req_install.py", line 271, in populate_link
self.link = self._wheel_cache.cached_wheel(self.link, self.name)
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/wheel.py", line 68, in cached_wheel
self._cache_dir, link, self._format_control, package_name)
File "/home/pi/oprint/local/lib/python2.7/site-packages/pip/wheel.py", line 129, in cached_wheel
wheel_names = os.listdir(root)
OSError: [Errno 13] Permission denied: '/home/guy/.cache/pip/wheels/3e/09/be/ca344cd1e68fd4d4d8872a25287e884a6f73557710efa51019'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The text was updated successfully, but these errors were encountered:
We're just using os.path.expanduser("~/.cache/pip") which uses the $HOME variable to replace ~ unless that isn't set, then it looks the user's home directory up in the passwd database. The reason sudo -H fixes this, is because by default sudo doesn't change the $HOME directory when you run a command.
Strange, because it finds the home user outside the chroot. It might mean the $HOME variable does not update when executing chroot.
What makes no sense is that all other commands seem to figure it out.
Ideas on testing this are welcome.
This is going to be either an environment bug or a Python bug of some kind. We're just using the standard library APIs. I would see if you get the same behavior just doing python -c "import os.path; print(os.path.expanduser('~'))" and if so, report it upstream to Python itself.
Description:
I am trying to run
sudo -u pi /home/pi/oprint/bin/pip install cryptography
as part of OctoPi's build, which runs inside a chroot script.However it seems that this command somehow managed to see beyond the chroot and resolves the cache folder to be
/home/pi/.cache/pip
. Whereguy
is the user outside my chroot. I am not sure even how it knows that. But it does, and it breaks the installation.This happens only in the Ubuntu chroot, not in the Debian Jessie one.
Adding the
-H
option to the sudo fixes the install, and is the current workaround i am using, but still the cache folder is shows up in this lineoptions.cache_dir
variable (if I stick aprint
line I can see thatoptions.cache_dir
is pointing out of the chroot, even with-H
flag on.Two questions:
What I've run:
log:
The text was updated successfully, but these errors were encountered: