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

Fix "make run" without debug mode #458

Merged
merged 1 commit into from
Nov 30, 2023
Merged

Conversation

vincent-olivert-riera
Copy link
Contributor

No description provided.

When running "make run" in non-debug mode, collectstatic needs to be
run, otherwise we will see errors like this one:

  ValueError: Missing staticfiles manifest entry for "vue.global.prod.js"
@vincent-olivert-riera vincent-olivert-riera requested a review from a team as a code owner November 28, 2023 09:10
Copy link
Collaborator

@kfdm kfdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEBUG = env.bool("DEBUG", default=False)

Just a confirmation, but if we assume a django only developer that wrote DEBUG=1 into their ./.env file then this would not have any effect, only if a user runs export DEBUG=1 (or similar) into their shell. Is this something we're worried about confusing the user with ? I'm not aware of there being a simple way to have make pick up a .env file for this edge case.

promgen/promgen/settings.py

Lines 163 to 170 in a2b6412

try:
# If whitenoise is not available, we will remove it from our middleware
import whitenoise.middleware # NOQA
except ImportError:
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
MIDDLEWARE.remove("whitenoise.middleware.WhiteNoiseMiddleware")
else:
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

Alternatively is there some setting we could be using here that would avoid the need for collectstatic when running with dev ?

@vincent-olivert-riera
Copy link
Contributor Author

vincent-olivert-riera commented Nov 29, 2023

Just a confirmation, but if we assume a django only developer that wrote DEBUG=1 into their ./.env file then this would not have any effect, only if a user runs export DEBUG=1 (or similar) into their shell. Is this something we're worried about confusing the user with ? I'm not aware of there being a simple way to have make pick up a .env file for this edge case.

If you have DEBUG=1 either in the .env file or defined in your shell, you will be fine because make run will end up running the development server, where the manifests for static files are not necessary.

If you don't have DEBUG=1 in the .env file or defined in the shell, then make run will end up running the production server, where the manifests for static files are necessary. For that, you need to run collectstatic to ensure all the manifests are in place.

So, if you want to run the production server using make run instead of Docker, then you need the Makefile to detect that situation and run collectstatic. This is what this patch does.

Alternatively is there some setting we could be using here that would avoid the need for collectstatic when running with dev ?

There must have been some misunderstanding here. collectstatic is not needed "when running with dev". I assume by "dev" you mean DEBUG=1.


If there was a misunderstanding caused by the lack of detail (or a poorly written) commit message, let me know and I will try to improve it.

@@ -114,6 +114,9 @@ migrate: $(APP_BIN)
.PHONY: run
## Django: Run development server
run: migrate
ifneq ($(DEBUG),1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misread ifneq as if 😅

@kfdm kfdm merged commit 963b8e0 into master Nov 30, 2023
5 checks passed
@kfdm kfdm deleted the fix-make-run-without-debug-mode branch November 30, 2023 01:32
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