serverless-python-requirements: Problem with pip cache permissions
I’m getting some issues with the docker based build and file permissions inside of the container. Any ideas?
Here are the configuration options:
custom:
pythonRequirements:
zip: true
dockerizePip: true
And here is the error message I’m getting:
Serverless: Removing Python requirements helper...
Serverless: Adding Python requirements helper...
Serverless: Parsing Python requirements.txt
Serverless: Installing required Python packages for runtime python2.7...
Serverless: Docker Image: lambci/lambda:build-python2.7
Error --------------------------------------------------
The directory '/root/.cache/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 '/root/.cache' 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.
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run
requirement_set.prepare_files(finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 281, in populate_link
self.link = self._wheel_cache.cached_wheel(self.link, self.name)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 68, in cached_wheel
self._cache_dir, link, self._format_control, package_name)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 129, in cached_wheel
wheel_names = os.listdir(root)
OSError: [Errno 13] Permission denied: '/root/.cache/wheels/44/56/6f/d5ac6dce9c887d96df2cd7b27ed0a6dd9357ef82b951ebb777'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: darwin
Node Version: 8.4.0
Serverless Version: 1.20.2
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24
Commits related to this issue
- Only pass UID option to Docker on Linux closes #62 and closes #21 — committed to serverless/serverless-python-requirements by dschep 7 years ago
- Only pass UID option to Docker on Linux closes #62 and closes #21 — committed to serverless/serverless-python-requirements by dschep 7 years ago
For now I’ve fixed this by using
I’ll try your branch next
@dschep yep! Just removing the line resolved this. Not sure it will break anything on other OSes doing this but it resolved the issue on Ubuntu 16.04.
@AndrewFarley and @dschep I’m seeing this issue on Ubuntu. Is the fix here supposed to work on other OSes? Or is there an alternative workaround suggested?
Thanks guys… just tried the patch locally also, works great on OS-X. Cheers!
+1 been having this problem months ago on OS-X. I started manually packaging that project, but a new project I wanted to use this and found this bug report just now. Removing the -u option fixed this for me. I wouldn’t mind creating a MR to help fix this… but I’m not sure the right way to fix this. I can do a noDockerUser as suggested above, or perhaps detect the host OS and skip the -u option altogether if on OS-X.
Thoughts/ideas/feedback from other contributors?