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

webassets.exceptions.FilterError [less] #140

Open
smurf-U opened this issue Sep 23, 2019 · 0 comments
Open

webassets.exceptions.FilterError [less] #140

smurf-U opened this issue Sep 23, 2019 · 0 comments

Comments

@smurf-U
Copy link

smurf-U commented Sep 23, 2019

assets_frontend_css = [
    'website/src/scss/color.less',
    'website/src/scss/common.less',
]
assets_bundles = {

    'assets_frontend_css': Bundle(
        *assets_frontend_css,
        output='gen/assets_frontend.css',
        filters='less,cssmin', extra={'rel': 'stylesheet/css'}),
}
app = Flask(__name__)
assets = Environment(app)
assets.register(assets_bundles)

color.less

@primary-color : #48b1bf;
@secondary-color: #646464;

common.less

body{
    background: @primary-color;
    color: @secondary-color;
}

Error give as below,

webassets.exceptions.FilterError
webassets.exceptions.FilterError: less: subprocess returned a non-success result code: 1, stdout=b'', stderr=b'\x1b[31mNameError: variable @primary-color is undefined\x1b[39m\x1b[31m in \x1b[39m-\x1b[90m on line 2, column 17:\x1b[39m\n\x1b[90m1 body{\x1b[39m\n2     background: \x1b[7m\x1b[31m\x1b[1m@\x1b[22mprimary-color;\x1b[39m\x1b[27m\n\x1b[90m3     color: @secondary-color;\x1b[39m\x1b[0m\x1b[0m\n\n'

Traceback (most recent call last)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/kaushal/flask_workspace/portfolio/app/website/controllers.py", line 32, in index
return render_template("index.html")
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/home/kaushal/.local/lib/python3.6/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/home/kaushal/.local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/home/kaushal/.local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/home/kaushal/.local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/kaushal/.local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/home/kaushal/flask_workspace/portfolio/app/website/templates/index.html", line 10, in top-level template code
{% assets "assets_frontend_css" %}
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/ext/jinja2.py", line 186, in _render_assets
urls = bundle.urls()
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/bundle.py", line 806, in urls
urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs))
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/bundle.py", line 765, in _urls
*args, **kwargs)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/bundle.py", line 619, in _build
force, disable_cache=disable_cache, extra_filters=extra_filters)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/bundle.py", line 543, in _merge_and_apply
kwargs=item_data)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/merge.py", line 276, in apply
return self._wrap_cache(key, func)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/merge.py", line 218, in _wrap_cache
content = func().getvalue()
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/merge.py", line 251, in func
getattr(filter, type)(data, out, **kwargs_final)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/filter/less.py", line 139, in input
self._apply_less(_in, out, source_path)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/filter/less.py", line 131, in _apply_less
self.subprocess(args, out, in_)
File "/home/kaushal/.local/lib/python3.6/site-packages/webassets/filter/__init__.py", line 527, in subprocess
proc.returncode, stdout, stderr))
webassets.exceptions.FilterError: less: subprocess returned a non-success result code: 1, stdout=b'', stderr=b'\x1b[31mNameError: variable @primary-color is undefined\x1b[39m\x1b[31m in \x1b[39m-\x1b[90m on line 2, column 17:\x1b[39m\n\x1b[90m1 body{\x1b[39m\n2 background: \x1b[7m\x1b[31m\x1b[1m@\x1b[22mprimary-color;\x1b[39m\x1b[27m\n\x1b[90m3 color: @secondary-color;\x1b[39m\x1b[0m\x1b[0m\n\n'
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.
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

No branches or pull requests

1 participant