LibrePhotos / librephotos-linux

Here you can find the installation script for a local Linux install.
MIT License
47 stars 15 forks source link

Environment variable not set :SECRET_KEY #55

Open cahaya42 opened 1 year ago

cahaya42 commented 1 year ago

After a fresh install, I ran librephotos-cli clear_cache

Traceback (most recent call last):
  File "/usr/lib/librephotos/backend/manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/core/management/init.py", line 345, in execute
    settings.INSTALLED_APPS
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/conf/init.py", line 82, in getattr
    self._setup(name)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/conf/init.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/librephotos/.local/lib/python3.8/site-packages/django/conf/init.py", line 170, in init
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/librephotos/backend/ownphotos/settings.py", line 26, in <module>
    raise NameError("Environment variable not set :" + envvar)
NameError: Environment variable not set :SECRET_KEY

Solution Add the following line to /etc/librephotos/librephotos-backend.env

SECRET_KEY=$BASE_LOGS/secret.key

Ideally, this should be added to resources/etc/librephotos/librephotos-backend.env

derneuere commented 1 year ago

https://github.com/LibrePhotos/librephotos-linux/blob/main/resources/bin/librephotos-backend

It should read out the secret key anyway, because of this entrypoint file. We either create a new one and read it, or we read an old one. I am not sure, why it's not working on your system.