Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve permission error text #64

Merged
merged 3 commits into from
Nov 7, 2023
Merged

Improve permission error text #64

merged 3 commits into from
Nov 7, 2023

Conversation

cthoyt
Copy link
Owner

@cthoyt cthoyt commented Oct 30, 2023

I was sent the following traceback which seems to correspond to someone who is using the Bioregistry, which has PyStow as a transitive dependency. They call code that invokes the Bioregistry, which imports PyStow and tries to create a README file in its default folder. However, the default folder is created in the home directory of the server, which is /var/www, and this user doesn't have permission to write in that folder.

Therefore, the solution is to change the PyStow configuration to overwrite the default location and pick somewhere where the user has write privileges. Changing the default Pystow location can be done by following instructions here: https://pystow.readthedocs.io/en/latest/installation.html#configuration

Traceback (most recent call last): File "signorValidator.py", line 5, in #import bioregistry File "/usr/local/lib/python3.8/dist-packages/bioregistry/__init__.py", line 5, in from .collection_api import get_collection, get_context # noqa:F401 File "/usr/local/lib/python3.8/dist-packages/bioregistry/collection_api.py", line 7, in from .resource_manager import manager File "/usr/local/lib/python3.8/dist-packages/bioregistry/resource_manager.py", line 27, in from .constants import ( File "/usr/local/lib/python3.8/dist-packages/bioregistry/constants.py", line 10, in import pystow File "/usr/local/lib/python3.8/dist-packages/pystow/__init__.py", line 53, in ensure_readme() File "/usr/local/lib/python3.8/dist-packages/pystow/utils.py", line 1010, in ensure_readme readme_path = get_home(ensure_exists=True).joinpath("README.md") File "/usr/local/lib/python3.8/dist-packages/pystow/utils.py", line 978, in get_home return getenv_path(PYSTOW_HOME_ENVVAR, default, ensure_exists=ensure_exists) File "/usr/local/lib/python3.8/dist-packages/pystow/utils.py", line 475, in getenv_path mkdir(rv, ensure_exists=ensure_exists) File "/usr/local/lib/python3.8/dist-packages/pystow/utils.py", line 433, in mkdir path.mkdir(exist_ok=True, parents=True) File "/usr/lib/python3.8/pathlib.py", line 1288, in mkdir self._accessor.mkdir(self, mode) PermissionError: [Errno 13] Permission denied: '/var/www/.data'

@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2023

Codecov Report

Merging #64 (15e0a64) into main (eecf60f) will decrease coverage by 0.11%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
- Coverage   66.80%   66.70%   -0.11%     
==========================================
  Files          10       10              
  Lines         946      949       +3     
  Branches      198      198              
==========================================
+ Hits          632      633       +1     
- Misses        291      293       +2     
  Partials       23       23              
Files Coverage Δ
src/pystow/utils.py 61.65% <50.00%> (-0.27%) ⬇️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@cthoyt cthoyt merged commit 47a81c3 into main Nov 7, 2023
19 checks passed
@cthoyt cthoyt deleted the improved-errors branch November 7, 2023 07:51
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants