pattern.web cache access error — IOError: [Errno 13] Permission denied
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
It appears pattern.web can't write to the directory the cache is kept in. When I try to download text from a URL object, I get a permission error:
Python 2.7.3 (default, Dec 18 2014, 19:10:20)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pattern.web
>>> urlObject=pattern.web.URL("http://google.com")
>>> urlResponse = urlObject.download()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pattern/web/__init__.py", line 426, in download
cache[id] = data
File "/usr/local/lib/python2.7/dist-packages/pattern/web/cache/__init__.py", line 96, in __setitem__
f = open(self._hash(k), "wb")
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pattern/web/cache/tmp/c7b920f57e553df2bb68272f61570210'
The permissions on /usr/local/lib/python-2.7/dist-packages/pattern/web/cache, subdir tmp and all files there were rwxr-sr-x, owner root and group "staff".
I had no problem with this when running python with sudo. And changing the owner and group to my user also made the error disappear. However neither of those workarounds seem like a good solution. Why should I need to give my user write access to /usr/local/lib? That seems to violate convention.
Running Ubuntu 12.04, python 2.7.3, pattern version 2.6. I installed pattern via pip, nothing fancy.
As seen on stackoverflow
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pattern/web/cache/init.py, especially setitem, and trace its caller in pattern/web/init.py at URL.download. Reproduce the download without sudo and verify that the cache can be used by a normal pip-installed user without changing permissions on /usr/local/lib.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100