I cannot for the life of me figure out how to get Sprockets to indicate which file caused a compilation error. I simply get errors like the following:
CoffeeScript
Completed 500 Internal Server Error in 14671ms (ActiveRecord: 281.4ms)
ExecJS::RuntimeError - SyntaxError: [stdin]:1:5: unexpected ,:
execjs (2.6.0) lib/execjs/external_runtime.rb:84:in `extract_result'
<backtrace continues>
Which can be triggered by adding the following to invalid syntax to an included .coffee file:
test,
Sass
Completed 500 Internal Server Error in 14671ms (ActiveRecord: 281.4ms)
Sass::SyntaxError - Invalid CSS after "0": expected expression (e.g. 1px, bold), was ";":
sass (3.4.20) lib/sass/scss/parser.rb:1179:in `expected'
<backtrace continues>
Which can be triggered by adding the a semicolon to a .sass file like so:
.test
top: 0;
In the case of warnings, the server logs show something helpful like
WARNING on line 9 of /path/to/file.sass: This selector doesn't have any properties and will not be rendered.
However, syntax errors simply seem to render a 500 error and tell me the line & column of the error, but not which file it was in. I've dug through the backtraces and they don't give any indication of the file in which the error occurred. How can I get the output to show the file in which the SyntaxError occurred?
Versions (everything latest as of this writing):
Keep reading that 500 error in your server. It should show the file and the line of the file that caused the error. Example below says app/assets/stylesheets/test.sass:2
Completed 500 Internal Server Error in 152ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (Invalid CSS after "0": expected expression (e.g. 1px, bold), was ";"):
2: <html>
3: <head>
4: <title>StackoverflowQuestions</title>
5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6: <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7: <%= csrf_meta_tags %>
8: </head>
app/assets/stylesheets/test.sass:2
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__1109435584510058936_70275420820360'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With