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)

Ruby\lib\ruby\gems\1.9.1\gems\execjs-1.4.0\lib\execjs\runtimes.rb

Find the line start with JScript = ExternalRuntime.new(
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 = ExternalRuntime.new(
    :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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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