Skip to content

core:backend: enable overriding BASE_DIR setting #906

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juliamrch
Copy link

@juliamrch juliamrch commented Apr 24, 2025

Purpose

Django backend currently collects static files and creates a /data directory to store them. DATA_DIR path is hardcoded as / and that can cause some systems to throw errors (Mac, PaaS, VMs and containers, and other systems with strict read-only permissions ). The error will look like this:

    os.makedirs(directory, exist_ok=True)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 217, in makedirs
  File "<frozen os>", line 217, in makedirs
  File "<frozen os>", line 227, in makedirs
OSError: [Errno 30] Read-only file system: '/data'

Changes in this PR allow developers to override the path in order to test the backend in any environment.

Proposal

I propose to avoid hardcoding the backend root as an absolute system path and replace it by the variable BASE_DIR, which is a standard Django convention. DATA_DIR will always point to Django project's root directory by default to create /data, unless specified otherwise.

Note: similar to #893 but with a different method.

@soyouzpanda
Copy link

I think the method used in #893 is better because you rely on the fact that BASE_DIR/data is writeable, which will not be the case in a system using NixOS (BASE_DIR will be referencing /nix/store)

@juliamrch
Copy link
Author

juliamrch commented Apr 25, 2025

I think the method used in #893 is better because you rely on the fact that BASE_DIR/data is writeable, which will not be the case in a system using NixOS (BASE_DIR will be referencing /nix/store)

I agree with your statement @soyouzpanda, but since it was hardcoded I sticked with the original design because I honestly wasn't completely sure about the necessity of sticking with the designated path.

This PR just stops DATA_DIR from pointing at some systems root and keeps it in what I concluded was the designated path on a UNIX OS. #893 provides more flexibility, and fixes both Nix and the current issue this PR adresses, so I'll let the reviewers choose which one suits this project better.

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