4

I have a Rails 4 application installed on RHEL 6 machine.

The production uses Passenger and Apache2.

Lately I've been trying to integrate Rake tasks into production as a scheduled job using Whenever Gem and Cron.

Whenever I try to run in production one of these Rake tasks, I get the following error:

rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

It is important to mention the NodeJS was installed on the machine. I can precompile assets, and so on. Specifically, the command node --version produces: v0.10.31

Here's my stack trace:

  rake aborted!
    ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/execjs-2.2.1/lib/execjs/runtimes.rb:51:in `autodetect'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)>'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    /var/www/eng_performance/shared/bundle/ruby/2.0.0/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in `require'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in `each'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in `block in require'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in `each'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in `require'
    /home/deploy/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.7.2/lib/bundler.rb:133:in `require'
    /var/www/eng_performance/releases/20141014084554/config/application.rb:7:in `<top (required)>'
    /var/www/eng_performance/releases/20141014084554/Rakefile:4:in `require'
    /var/www/eng_performance/releases/20141014084554/Rakefile:4:in `<top (required)>'
    (See full trace by running task with --trace)

Note: I've installed NodeJS as a compilation from source, because when I tried to install from the repo I got this error that I didn't know how to overcome:

Packages skipped because of dependency problems:
    c-ares19-1.9.1-5.el6.3.x86_64 from epel
    http-parser-2.0-4.20121128gitcd01361.el6.x86_64 from epel
    1:libuv-0.10.28-1.el6.x86_64 from epel
    nodejs-0.10.30-1.el6.x86_64 from epel
    1:v8-3.14.5.10-11.el6.x86_64 from epel
3
  • 1
    Could you check if gem 'therubyracer' is uncommented in your Gemfile?
    – R Milushev
    Oct 14, 2014 at 19:24
  • @RMilushev, thanks for the reply. As far as I understand, using therubyracer isn't recommended as to performance issues. I've found more than one thread like this: rubyracer vs nodejs. Are you aware to those issues? Were there any changes in some of the new versions of this gem?
    – cyber101
    Oct 15, 2014 at 6:09
  • 1
    I have bad experience with nodejs on my production Debian Linux server. It has to be installed in a very special way and we've decided to rely on therubyracer gem. I don't think there are performance issues, since it is a V8 js machine warper, nothing more or less.
    – R Milushev
    Oct 15, 2014 at 10:52

1 Answer 1

5

Well, finally, I was able to solve this :)

As it turns out, no was nothing wrong with node.js installation, but with the reference to it.

I have no idea why this was changed in the first place, but following this post solved the problem- i.e. by adding the symlink ln -s /usr/local/bin/node /usr/bin/node.

Note: I'm pretty sure that the symlink isn't the best practice. If there's anyone who can suggest another idea- I'd love to hear it..

Hopefully this was the last error I'll get with node.js. If another errors such as this will occur, therubyracer will provide an excellent backup solution.

1
  • Could someone comment why we even need JS env on production when we can use a web server to serve stuff precompiled in the first place, let alone a rake task that likely doesn't even need anything JS.
    – mlt
    Aug 31, 2021 at 18:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.