Error when running rails app - ExecJS::RuntimeErro

2019-01-06 21:23发布

问题:

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

回答1:

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/



回答2:

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)



回答3:

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. 


回答4:

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

Then application started running without any problem.



回答5:

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.