hasgeek / hasjob

Hasjob, the Hasgeek job board
https://hasjob.co
GNU Affero General Public License v3.0
234 stars 80 forks source link

LookupError: Missing asset file for app-css #604

Closed mr-karan closed 3 years ago

mr-karan commented 3 years ago

I'm trying to run this app inside Ubuntu 18.04 box. The steps I've followed (after setting up DB):

$ python manage.py createdb
$ cd hasjob/assets
$ yarn
$ yarn build

While trying to run the app:

web_1    |  * Serving Flask app "hasjob" (lazy loading)
web_1    |  * Environment: production
web_1    |    WARNING: This is a development server. Do not use it in a production deployment.
web_1    |    Use a production WSGI server instead.
web_1    |  * Debug mode: off
web_1    |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
web_1    | [2021-04-01 15:58:34,390] ERROR in app: Exception on / [GET]
web_1    | Traceback (most recent call last):
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
web_1    |     response = self.full_dispatch_request()
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
web_1    |     rv = self.handle_user_exception(e)
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
web_1    |     reraise(exc_type, exc_value, tb)
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
web_1    |     raise value
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
web_1    |     rv = self.dispatch_request()
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
web_1    |     return self.view_functions[rule.endpoint](**req.view_args)
web_1    |   File "/usr/local/lib/python3.9/site-packages/coaster/views/decorators.py", line 570, in decorated_function
web_1    |     render_template(templates[use_mimetype], **result),
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/templating.py", line 137, in render_template
web_1    |     return _render(
web_1    |   File "/usr/local/lib/python3.9/site-packages/flask/templating.py", line 120, in _render
web_1    |     rv = template.render(context)
web_1    |   File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
web_1    |     self.environment.handle_exception()
web_1    |   File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
web_1    |     reraise(*rewrite_traceback_stack(source=source))
web_1    |   File "/usr/local/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
web_1    |     raise value.with_traceback(tb)
web_1    |   File "/code/hasjob/hasjob/templates/index.html.jinja2", line 145, in top-level template code
web_1    |     {%- block footerscripts -%}
web_1    |   File "/code/hasjob/hasjob/templates/layout.html.jinja2", line 3, in top-level template code
web_1    |     {%- from "macros.html.jinja2" import campaign_header, campaign_script, filters_setup_script -%}
web_1    |   File "/usr/local/lib/python3.9/site-packages/baseframe/templates/baseframe.html.jinja2", line 4, in top-level template code
web_1    |     {%- extends 'baseframe/bootstrap3/baseframe.html.jinja2' -%}
web_1    |   File "/usr/local/lib/python3.9/site-packages/baseframe/templates/baseframe/bootstrap3/baseframe.html.jinja2", line 58, in top-level template code
web_1    |     {%- block layoutheaders %}{% block pageheaders %}{% endblock %}{% endblock %}
web_1    |   File "/code/hasjob/hasjob/templates/layout.html.jinja2", line 41, in block "layoutheaders"
web_1    |     <link rel="stylesheet" type="text/css" href="{{ asset_path('app-css') }}" />
web_1    |   File "/usr/local/lib/python3.9/site-packages/baseframe/views.py", line 139, in asset_path
web_1    |     raise LookupError("Missing asset file for {bundle}.".format(bundle=bundle_key))
web_1    | LookupError: Missing asset file for app-css.
web_1    | 172.23.0.1 - - [01/Apr/2021 15:58:34] "GET / HTTP/1.1" 500 -

The value of ASSET_BASE_PATH is set to '/static'. There's a /static folder on my local installation (which came after yarn build command).

ls -laht                 
total 28K
drwxrwxr-x  4 karan karan 4.0K Apr  1 20:19 .
drwxrwxr-x  2 karan karan 4.0K Apr  1 20:13 css
drwxrwxr-x 10 karan karan 4.0K Apr  1 19:55 ..
-rw-rw-r--  1 karan karan 1.7K Mar 26 14:36 embed.js
drwxrwxr-x  2 karan karan 4.0K Mar 26 14:36 img
-rw-rw-r--  1 karan karan  461 Mar 26 14:36 opensearch.xml
-rw-rw-r--  1 karan karan   94 Mar 26 14:36 robots.txt

The error seems to be coming for a CSS file, but I do have baseframe-picked.css inside the static/css directory.

Is there any step I'm missing? Would love some help debugging this.

Thanks

jace commented 3 years ago

Have you tried make from the base folder? Baseframe also has a make step, but that should be handled for you in its setup.py, unless something has broken lately.

mr-karan commented 3 years ago

Fixed it with this in my settings.py:

ASSET_MANIFEST_PATH = 'static/build/manifest.json'
ASSET_BASE_PATH = '/static/build'
STATIC_SUBDOMAIN = ''

Marking as resolved, thanks!

jace commented 3 years ago

Place your local settings in instance/development.py or instance/production.py so they aren't in conflict with the git-backed instance/settings.py. The choice of development or production (default) comes from the FLASK_ENV environment variable.