17

I tried googling this and I haven't found an answer yet to my problem.

I am trying to run a simple controller script through rails and it is giving me this error when I reach the page.

ExecJS::RuntimeError in Say#hello

Obviously Say is the controller and hello is the method. Further down the page I get more info about the error.

dyld: unknown required load command 0x80000022
(in /Users/JoeMoe/Sites/demoRails/app/assets/javascripts/say.js.coffee)

I have checked this file and there is nothing in it besides the commented code. Is there supposed to be something in here?

Here is whats in the say.js.coffee file

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

Down the page some more I see I can do an Application Trace which shows me.

app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__169683399_21885150'

I can also do the framework trace as well. This is going to be a long list by the way.

execjs (1.2.9) lib/execjs/external_runtime.rb:129:in `exec_runtime'
execjs (1.2.9) lib/execjs/external_runtime.rb:27:in `block in exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
execjs (1.2.9) lib/execjs/external_runtime.rb:26:in `exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:18:in `eval'
execjs (1.2.9) lib/execjs/external_runtime.rb:32:in `call'
coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'
tilt (1.3.3) lib/tilt/coffee.rb:46:in `evaluate'
tilt (1.3.3) lib/tilt/template.rb:76:in `render'
sprockets (2.0.3) lib/sprockets/context.rb:175:in `block in evaluate'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `each'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `evaluate'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:171:in`build_dependency_context_and_body'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:135:in `dependency_context'
....

There is more but its a pretty long list and I don't want to bore you. Let me know if you need the full list and I will paste it in.

I am running Mac OS X with the following - Ruby 1.9.2 - Rails 3.1.0 - Gem 1.8.10 - sqlite3 3.7.9

JoeMoe1984
  • 1,912
  • 3
  • 21
  • 31
  • 2
    Do you mind pasting the commented code? Sprockets reads directives from the comments, and `unknown required load` sounds like maybe there's a character upsetting sprockets... – Andrew Dec 02 '11 at 21:11
  • I just edited the post to show the commented code in the file. Thanks for looking into it I really appreciate it. – JoeMoe1984 Dec 02 '11 at 21:35
  • which js-engine are you running and how did you install it? – phoet Dec 02 '11 at 21:53
  • @phoet I am not sure how to answer that one. Is there a way to see which one I am using? something is running and it works for the Welcome page when you first test a new rails app. – JoeMoe1984 Dec 02 '11 at 23:33
  • what happens when you type `coffee` in Terminal? – firien Dec 03 '11 at 01:12
  • ExecJS doesn't actually execute the JS stuff, it calls on another one like therubyracer. You need to have at least one of the runtimes listed on https://github.com/sstephenson/execjs installed. – arrtchiu Dec 03 '11 at 01:14
  • As a follow up to what @arrtchiu said, I would add gem 'execjs' and gem 'therubyracer' in your Gemfile. And try running bundle install command. – Jason Kim Dec 03 '11 at 06:32
  • I see. That was never mentioned in any of the tutorials I was following but I will give it a shot and let you know. Also the coffee command in terminal was not found. – JoeMoe1984 Dec 03 '11 at 19:22
  • Actually I have node.js installed. I had found that page before on github. The coffee command does nothing as it doesn't exist but I ran gem list and i found the following gems installed - coffee-rails(3.1.1), coffee-script(2.2.0), coffee-script-source(1.1.3); – JoeMoe1984 Dec 03 '11 at 19:34
  • I just typed in the terminal "node -v" and I got the following response "dyld: unknown required load command 0x80000022 Trace/BPT/ trap". I don't understand this because I clearly downloaded the nodejs package file and installed it. Is there a step Im missing? – JoeMoe1984 Dec 03 '11 at 19:52
  • Did you try adding 'therubyracer' gem? What happened? – Andrew Dec 04 '11 at 18:35
  • @Andrew Nothing. Just the same thing. – JoeMoe1984 Dec 07 '11 at 23:50

6 Answers6

20

you have to install an additional gem for javascript. edit gemfile and add gem 'therubyracer'. You can then run bundle to install the new gem.

here is your solution in detail: http://www.railszilla.com/2011/12/rails-3-coffescript-execjs/

Andrew White
  • 600
  • 1
  • 9
  • 29
RailsZilla
  • 224
  • 1
  • 2
  • Hey Sorry for the late response. I was working on my windows computer with no problem. This was the solution. After doing a little research I understand more on how to use the gemfile and the bundle install command. Thanks – JoeMoe1984 Jan 23 '12 at 12:29
18

It happened to me too! You need to install "nodejs". As I work with Ubuntu Linux I did:

apt-get install nodejs 

Source: http://forums.pragprog.com/forums/148/topics/9665#posts-26576 (Sam Ruby's post)

Hizqeel
  • 947
  • 3
  • 20
  • 23
Martin
  • 197
  • 2
  • 1
    I am running Ruby 1.8.7 and Rails 3.2 on Ubuntu 11.10. I did get this issue, and I tried to the top post "install 'therubyracer' gem" and it did not work for me. I tried to install nodejs, and it worked after a restart of the rails server. I do not know if both are required, or just one of the package installs a required. Just a heads up. – Huckphin Mar 25 '12 at 23:23
  • I was having this same problem on Windows and installing [node.js](http://nodejs.org/) did the trick. – Ajedi32 Jan 26 '13 at 03:22
  • Thanks. It worked for me too on Windows 8. Had to restart cmd prompt though. – obesechicken13 Mar 30 '14 at 00:10
  • I required to add the gem 'node' to my gemfile as well on windows 8. Thanks. – bastijn Oct 05 '14 at 08:06
  • Needed to update node on mac from 8 to v10 after upgrading to ruby 2.5.1 from 2.3.1 then it worked. – bkunzi01 Oct 10 '18 at 02:32
6

If you are having this problem in production server this might be due to memory usage. while doing assets precompilation server use lot of memory.

consider restarting your production server. 
Aleem
  • 549
  • 6
  • 13
3

None of the above worked for me . . . I installed gem 'coffee-script-source', '1.8.0'.

Then application started running without any problem.

ajinkya Jahagirdar
  • 65
  • 1
  • 1
  • 12
1

It looks like you might be missing a few gems.

Add to your Gemfile:

gem 'therubyracer'
gem 'execjs'

And then run $ bundle install to install them.

Will
  • 4,585
  • 1
  • 26
  • 48
PanXo
  • 21
  • 1
0

Seems like javascript runner is missing you just need to do

gem 'therubyracer'

then

 bundle install

then restart the server if you are using the production server then consider restart the production server.

It will definitely solve your problem,

cheers

Ali Hassan Mirza
  • 552
  • 11
  • 23