samuelclay / NewsBlur

NewsBlur is a personal news reader that brings people together to talk about the world. A new sound of an old instrument.
http://www.newsblur.com
MIT License
6.91k stars 1k forks source link

Permission error when running startup #1830

Closed dzx-dzx closed 1 year ago

dzx-dzx commented 1 year ago

I'm trying to set up the project with make nb command when this appears:

 ---> Starting NewsBlur development server...
Traceback (most recent call last):
  File "/srv/newsblur/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 345, in execute
    settings.INSTALLED_APPS
  File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/srv/newsblur/newsblur_web/settings.py", line 666, in <module>
    clear_prometheus_aggregation_stats()
  File "/srv/newsblur/newsblur_web/settings.py", line 651, in clear_prometheus_aggregation_stats
    os.makedirs(prom_folder, exist_ok=True)
  File "/usr/local/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/srv/newsblur/.prom_cache'
make: *** [Makefile:38: migrate] Error 137

Other issues suggest chmoding the folder to 777, but that doesn't sound safe... I wonder if there is any other solution?

samuelclay commented 1 year ago

You'll want to chown ``whoami`` .prom_cache matching the user that's running docker, which might be root or your local user.

dzx-dzx commented 1 year ago

the user that's running docker

Can I know exactly who that is by injecting some code?

dzx-dzx commented 1 year ago

I run

docker exec -it newsblur_web echo ```id -u```

Before the migration command docker exec -it newsblur_web ./manage.py migrate which caused the problem, and it returns the id that is the same as my user's, does that mean the following commands are run with my identity?

dzx-dzx commented 1 year ago

For future reader: you could be, like me, a victim of Docker Desktop. See https://forums.docker.com/t/bind-mount-permissions-unexpected-mounting-as-root-root/129328/7