0

Confused at what to do. Default rails install by the RailsInstaller.

started a new demo app. Using rails 3.2.14.

created a controller

rails generate controller Say hello goodbye

However whenever I navigate to the localhost it returns an execjs error.

So for

http://localhost:3000/say/hello

I received

 ExecJS::RuntimeError in Say#hello

Showing c:/work/demo/app/views/layouts/application.html.erb where line #6 raised:


  (in c:/work/demo/app/assets/javascripts/say.js.coffee)

Extracted source (around line #6):

3: <head>
4:   <title>Demo</title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>

Rails.root: c:/work/demo

I have tried searching for solutions but the only one I thought seemed applicable hasn't helped.

I added to my gemfile the below and did bundle update. No Success.

gem 'execjs'
gem 'therubyracer', :platforms => :ruby

What should I do?

EDIT

gemfile.lock http://pastebin.com/hGPJpxLp

2

5 Answers 5

1

Find ExecJS's runtimes.rb file.

bundle show execjs

Make a backup. Open the runtimes.rb and edit. Find the part that starts with the line JScript = ExternalRuntime.new(. On the line containing :command => "cscript //E:jscript //Nologo //U", - remove the //U only. Now in the line containing :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE - change UTF-16LE to UTF-8 . Save changes. Result should be like:

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
)

restart rails s, problem should be solved.

Sign up to request clarification or add additional context in comments.

Comments

1

Use gem install node . I don't know why this works but it works .

Comments

0

Make sure you have gem 'therubyracer' and gem 'execjs' under assets group then run bundle install , also you can try Node.js instead of execjs

3 Comments

please read this in his question: I added to my gemfile the below and did bundle update.
i did , but maybe they not inside the assets block !, that happens with me before
yea, you are right, it's hard to say where these gems are placed in.
0

I also had a problem, After the R&D I installed node.js (http://nodejs.org/download/) the problem become solved.

Comments

0

adding the gem gem 'execjs' did it for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.