Error when running Rails with CoffeeScript – ExecJS::RuntimeError

Rails 3.1 comes with CoffeeScript. But it has weird error when I run first rails application. The error is ExecJS::RuntimeError and point to the code around importing CoffeeScript. After google this problem I found this solution that work for me.

Edit ExecJS’s runtimes.rb (should backup before edit)


Find the line start with JScript =
On the line :command => “cscript //E:jscript //Nologo //U”,
– remove //U
On the line :encoding => ‘UTF-16LE’ # CScript with //U returns UTF-16LE
– change ‘UTF-16LE’ to ‘UTF-8’

It should look like this.

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

Save it and restart rails server.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s