ruby-on-railsruby-on-rails-4therubyracer

The Ruby Racer, RuntimeError - SyntaxError: unexpected indentation


After an upgrade of ruby and rails performed on an old app, I get the following error when trying to access to any of the app views:

SyntaxError: [stdin]:3:1: unexpected indentation

It seems that some file related to The Ruby Racer gem may be causing this issue.

Ruby 2.3.1p112, Rails 4.0.13, therubyracer 0.12.3

In the server log:

ExecJS::RuntimeError - SyntaxError: [stdin]:3:1: unexpected indentation:
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:98:in `wrap_error'
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:47:in `rescue in block in call'
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:44:in `block in call'
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:73:in `lock'
  execjs (2.7.0) lib/execjs/ruby_racer_runtime.rb:43:in `call'
  coffee-script (2.4.1) lib/coffee_script.rb:78:in `compile'

Update

Using a previous version of therubyracer such as gem 'therubyracer', '~> 0.10.2' does not fix the problem.


Solution

  • There's a compilation error during the compilation of one of your coffee scripts. You should check the coffee files inside your assets/javascript folder.

    To help you debug more easily where the problem is (which line), you can try to install coffee-script manually (http://coffeescript.org) and use the command line compiler.