The Ruby Racer, RuntimeError - SyntaxError: unexpected indentation

The Ruby Racer, RuntimeError - SyntaxError: unexpected indentation

在对旧应用程序执行 ruby 和 rails 升级后,我在尝试访问任何应用程序视图时收到以下错误:

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

似乎与 Ruby Racer gem 相关的某些文件可能导致此问题。

Ruby 2.3.1p112,Rails 4.0.13,ruby赛车 0.12.3

在服务器日志中:

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'

更新

使用 rubyracer 的早期版本,例如 gem 'therubyracer', '~> 0.10.2' 不能解决问题。

编译您的某个咖啡脚本时出现编译错误。您应该检查 assets/javascript 文件夹中的 coffee 文件。

为了帮助您更轻松地调试问题出在哪里(哪一行),您可以尝试手动安装coffee-script(http://coffeescript.org)并使用命令行编译器。