NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.29k stars 13.54k forks source link

`mealie` crashes on start-up, complaining about access to `/app/data` #329020

Open CoderThomasB opened 1 month ago

CoderThomasB commented 1 month ago

Describe the bug

When the mealie application is run from within a nix-shell, it crashes, complaining that it can't access /app/data

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Run nix-shell -p mealie --run mealie

Expected behaviour

Either mealie starts up without an error, or an explanation on how to run the application correctly is provided in the package description or printed on start up.

Screenshots/Output

[2024-07-22 11:35:08 +1200] [29193] [INFO] Starting gunicorn 21.2.0
[2024-07-22 11:35:08 +1200] [29193] [INFO] Listening at: http://127.0.0.1:8000 (29193)
[2024-07-22 11:35:08 +1200] [29193] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2024-07-22 11:35:08 +1200] [29194] [INFO] Booting worker with pid: 29194
[2024-07-22 11:35:08 +1200] [29194] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/app/data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/nix/store/yhl2rgd8qpfqq8v1sfb0lczn0wzrxdlc-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/workers.py", line 68, in init_process
    super().init_process()
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
                ^^^^^^^^^^^^^^^
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
                    ^^^^^^^^^^^
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
           ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/f2am1hl3f5ic0cw50w9pz5nsr9q61wss-python3.11-gunicorn-21.2.0/lib/python3.11/site-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/app.py", line 8, in <module>
    from mealie.core.root_logger import get_logger
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/core/root_logger.py", line 57, in <module>
    logger_config = get_logger_config()
                    ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/core/root_logger.py", line 27, in get_logger_config
    settings = get_app_settings()
               ^^^^^^^^^^^^^^^^^^
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/core/config.py", line 40, in get_app_settings
    return app_settings_constructor(env_file=ENV, production=PRODUCTION, data_dir=determine_data_dir())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/core/settings/settings.py", line 190, in app_settings_constructor
    **{"SECRET": determine_secrets(data_dir, production)},
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/y7ypgcik6hn6943lg35hadv5ppph1qpb-python3.11-mealie-1.2.0/lib/python3.11/site-packages/mealie/core/settings/settings.py", line 20, in determine_secrets
    data_dir.mkdir(parents=True, exist_ok=True)
  File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/pathlib.py", line 1120, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/app'
[2024-07-22 11:35:08 +1200] [29194] [INFO] Worker exiting (pid: 29194)
[2024-07-22 11:35:08 +1200] [29193] [ERROR] Worker (pid:29194) exited with code 3
[2024-07-22 11:35:08 +1200] [29193] [ERROR] Shutting down: Master
[2024-07-22 11:35:08 +1200] [29193] [ERROR] Reason: Worker failed to boot.

Additional context

It's possible that mealie was intended to be run from within a specialised environment, if so this would not be a bug, but if this were the case, It should probably be that either in the package description or somewhere else this be noted.

Notify maintainers

@litchipi

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.37, NixOS, 24.05 (Uakari), 24.05.2580.194846768975`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.4`
 - channels(root): `"nixos-24.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 1 month ago

Did you try with the actual mealie module? (services.mealie.enable = true;)?

CoderThomasB commented 1 month ago

Did you try with the actual mealie module? (services.mealie.enable = true;)?

No, I ran it directly from the terminal using nix-shell -p mealie --run mealie. If it isn't intended to be run from a terminal, should I close this issue?

eclairevoyant commented 1 month ago

Yeah if there's a nixos module for something you generally want to use it, but if you still have the same error with the module then keeping the issue open makes sense.

litchipi commented 1 month ago

@CoderThomasB mealie was made for service inside a docker container. We had to patch the sources in order to change the data dir based on some env vars. So you'll need to setup environment variables like what is done on the module (See https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/web-apps/mealie.nix#L58)

@eclairevoyant Do you think a specific description (or maybe just a comment) in the package should be done ? Or should I just close this issue as "not a bug" ?