Could not find a JavaScript runtime despite therubyracer and nodejs being installed
Asked Answered
L

3

8

I'm trying to run a Rails app on CentOS 5 and keep getting this error:

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

I have both NodeJS (v0.8.15) and therubyracer (libv8) installed.

Here is my gem list:

*** LOCAL GEMS ***

actionmailer (3.2.9, 3.2.8)
actionpack (3.2.9, 3.2.8)
activemodel (3.2.9, 3.2.8)
activerecord (3.2.9, 3.2.8)
activerecord-sqlserver-adapter (3.2.10)
activeresource (3.2.9, 3.2.8)
activesupport (3.2.9, 3.2.8)
arel (3.0.2)
builder (3.1.4, 3.0.4)
bundler (1.2.3, 1.2.2)
capistrano (2.13.5)
commonjs (0.2.6)
daemon_controller (1.1.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (4.1.0)
factory_girl_rails (4.1.0)
fastthread (1.0.7)
haml (3.1.7)
haml-rails (0.3.5)
highline (1.6.15)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.4, 2.1.3)
json (1.7.5)
less (2.2.2)
less-rails (2.2.6)
libv8 (3.11.8.4)
mail (2.5.3, 2.4.4)
mime-types (1.19)
multi_json (1.5.0, 1.3.7)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.6.2, 2.6.1)
net-ssh-gateway (1.1.0)
nokogiri (1.5.6, 1.5.5)
passenger (3.0.18)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.9, 3.2.8)
railties (3.2.9, 3.2.8)
rake (10.0.3, 10.0.2, 10.0.1)
rdoc (3.12)
ref (1.0.2)
rspec-core (2.12.2, 2.12.0)
rspec-expectations (2.12.1, 2.12.0)
rspec-mocks (2.12.1, 2.12.0)
rspec-rails (2.12.0)
ruby-odbc (0.99994)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)
sass (3.2.4, 3.2.3)
sass-rails (3.2.5)
sprockets (2.8.2, 2.2.2, 2.1.3)
sqlite3 (1.3.6)
therubyracer (0.11.0, 0.11.0beta8 x86-linux, 0.10.2)
thor (0.16.0)
tilt (1.3.3)
tiny_tds (0.5.1)
treetop (1.4.12)
twitter-bootstrap-rails (2.1.9, 2.1.6)
tzinfo (0.3.35)
uglifier (1.3.0)
webrat (0.7.3)
will_paginate (3.0.3)
will_paginate-bootstrap (0.2.1)

here is my gem file:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'haml'
gem 'will_paginate'
gem 'will_paginate-bootstrap'
gem 'activerecord-sqlserver-adapter'
gem 'ruby-odbc'
gem 'tiny_tds'
gem 'jquery-rails'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby

group :assets do
  gem 'execjs'
  gem 'sass-rails'
  gem 'therubyracer', :platforms => :ruby
  gem 'uglifier'
  gem 'jquery-rails'
  gem 'twitter-bootstrap-rails'
end

group :test do
  gem 'rspec-rails'
  gem 'webrat'
  gem 'factory_girl_rails'
end    

group :development do
  gem 'rspec-rails'
  gem 'haml-rails'
end

What have I done wrong and what can I do to make execjs see any of JS runtime installed?

Lame answered 27/12, 2012 at 14:46 Comment(3)
are you using MRI/YARV or jRuby?Indira
How did you install nodejs? "make install" or "rpmbuild -ba nodejs.spec"Hunsaker
I've used the following topic - serverfault.com/questions/299288/… The first, it mentioned "make install"Lame
L
-1

Since no one can help directly with the problem, I've found solution of my own.

It's not directly solve described problem , but it worked for me

I've reinstalled OS from centos to Ubuntu Server - issue not only disappear but general configuration of rails were flawless. After that I've set up about 20-30 servers some with very exotic software - no single issues I cannot find solution on the first page of google results. I guess that CentOS not really very suitable for Rails.

Hope this experience will help those who encounter the same problem.

Lame answered 24/9, 2013 at 20:4 Comment(0)
H
2

The simplest and fastest way to resolve this problem is just by installing NodeJS.

If you indeed have installed NodeJS, it may be an SElinux issue, try this:

setenforce 0
Hunsaker answered 27/12, 2012 at 14:55 Comment(3)
As I said, I do have nodejs installed already: # node -v v0.8.15Lame
Thank you for such unusual solution! But no luck :( # /usr/sbin/setenforce 0 /usr/sbin/setenforce: SELinux is disabled But keep getting the same error.Lame
I had to put nodejs/bin in my user path as well to get it to work on CentOS 6Shennashensi
B
2

How about the following answer: install execjs and it should use node automatically for you:

gem install execjs

alternatively you can also try installing therubyracer and include it in your gem file

gem install therubyracer

then add it in your Gemfile:

gem "therubyracer"

source: https://teamtreehouse.com/forum/rails-server-error-could-not-find-a-javascript-runtime

Busk answered 9/8, 2014 at 16:27 Comment(1)
Adding gem "therubyracer" helped me outLoredo
L
-1

Since no one can help directly with the problem, I've found solution of my own.

It's not directly solve described problem , but it worked for me

I've reinstalled OS from centos to Ubuntu Server - issue not only disappear but general configuration of rails were flawless. After that I've set up about 20-30 servers some with very exotic software - no single issues I cannot find solution on the first page of google results. I guess that CentOS not really very suitable for Rails.

Hope this experience will help those who encounter the same problem.

Lame answered 24/9, 2013 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.