1

I have been trying to follow several tutorials on rails and each time I am hitting the following issue at the time of running rails s:

Started GET "/" for 127.0.0.1 at 2014-09-14 06:57:44 +0100
Connecting to database specified by database.yml
Processing by CarsController#index as HTML
  Car Load (1.0ms)  SELECT "cars".* FROM "cars"
  Rendered cars/index.html.erb within layouts/application (396.0ms)
Completed 500 Internal Server Error in 101655ms

ActionView::Template::Error (incomplete "\n" on UTF-16LE
  (in /cygdrive/c/rails/todolist/3/rails-angular-example-master/app/assets/javascripts/angular_app.js.coffee.erb)):
    3: <head>
    4:   <title>Angular</title>
    5:   <%= stylesheet_link_tag    "application", :media => "all" %>
    6:   <%= javascript_include_tag "application" %>
    7:   <%= csrf_meta_tags %>
    8: </head>
    9: <body>
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__988651031__1054838708'
  app/controllers/cars_controller.rb:6:in `index'
  config/initializers/quiet_assets.rb:8:in `call_with_quiet_assets'

Tutorial:https://github.com/wulftone/rails-angular-example

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
Exploring
  • 2,493
  • 11
  • 56
  • 97

1 Answers1

2

This occurs when ExecJS tries to process your assets (javascript and coffeescript) and your file encoding is not UTF-16LE.

Most popular fix: use an alternative ExecJS runtime

Probably the most popular fix is to use NodeJS as your ExecJS runtime. One way to do so:

  1. Install nodejs
  2. Set an environment varaible EXECJS_RUNTIME to Node
  3. Start up your Rails server

Alternative fix: modify existing configuration

Alternative to making another installation (NodeJS) is to modify the configuration of your default ExecJS runtime. I believe your system is using cscript.

Have a look at your execjs runtimes.rb file. (It is in your gems directory.) You can see the latest version of this file on github here. It contains the following:

JScript = ExternalRuntime.new(
  name:        "JScript",
  command:     "cscript //E:jscript //Nologo //U",
  runner_path: ExecJS.root + "/support/jscript_runner.js",
  encoding:    'UTF-16LE' # CScript with //U returns UTF-16LE
)

I can't advise you on the best course to take, but for the sake of getting a fix in place quickly, you may want to just edit this file (then restart your server).

  • You may find that removing the //U fixes the problem.
  • You may find that changing UTF-16LE to UTF-8 fixes the problem.
  • You may find that the combination of both of these steps fixes the problem.

These instructions are drawn from ExecJS::RuntimeError on Windows trying to follow rubytutorial

JellicleCat
  • 28,480
  • 24
  • 109
  • 162