Search code examples
javascriptruby-on-railsrubyruby-on-rails-5chartkick

Rails 5 - ExecJS::RuntimeError


My project was working fine, I was tweaking a chart made with chartkick and updating a HTML badge with ActionCable, when suddenly I get this error:

ExecJS::RuntimeError in Pages#create_session

Showing B:/.../app/views/layouts/application.html.erb where line #7 raised:

SyntaxError: [stdin]:14:32: unexpected end of input
Extracted source (around line #7):              
5    <%= csrf_meta_tags %>
6    <%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
7    <%= javascript_include_tag 'application', 'chartkick' %>
8     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
10  </head>

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___430303067_44605968'
app/controllers/pages_controller.rb:145:in `render_page'
app/controllers/pages_controller.rb:46:in `create_session'

I googled and found out that this Error means there is a problem with the JavaScript runtime on my system (I'm using Windows 10).


Things I've tried:

  1. Removing //= require_tree . from application.js - doesn't work for me because then all my JavaScript code doesn't work anymore (my project uses ActionCable)
  2. Modifying C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\execjs-2.7.0\lib\execjs\ ru‌​ntimes.rb as is detailed here - didn't fix it
  3. Adding 'therubyracer' gem - couldn't install it, this is the error message I got. That's the complete error message and then it's just done. As far as I can tell it can't install because Python 2 is not installed?
  4. As suggested here, I added the gem 'coffee-script-source' - didn't fix it and now I can't remove it because suddenly other gems depend on it? Weird.
  5. I have had Node.js installed ever since I started this project so that can't be it.

I'm using Windows 10, Ruby 2.3.0 and Rails 5.0.2 and this is my current Gemfile.

This is my application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require chartkick
//= require_tree .

I know there have been many posts with this issue, but after trying almost everything I'm kind of lost... Please help! =)


Solution

  • After Ziyan Junaideens pointer I searched all my CoffeeScript files and finally found I had left a method call unfinished... >_<

    received: (data) ->
        App.online_status.  #<--- right here
    

    So what did I learn? Never program when you are dead tired - or you'll spend the whole next day searching for the stupid mistake! ^^*