ExecJS::RuntimeUnavailable in Rails 4.1.4
Solution 1
Ubuntu Users
I'm on Ubuntu 11.04 and had similar issues. Installing Node.js fixed it.
As of Ubuntu 13.04 x64 you only need to run:
sudo apt-get install nodejs
This will solve the problem. CentOS/RedHat Users
sudo yum install nodejs
Solution 2
A quick and easy solution is to uncomment this line in Gemfile and run bundle install
again
gem 'therubyracer', platforms: :ruby
Solution 3
This has been answered in great detail by @KevinP here.
Following the link above, you need to go into Execjs's runtimes.rb
and change that line specified in his answer. After that, restart your server and it should start working.
The block that needs to be changed looks like this:
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
)
^ Credit to Kevin P.
I also answered this question a few days go here. https://stackoverflow.com/a/24591983/2456549
AlphonseJr
Updated on June 06, 2022Comments
-
AlphonseJr about 2 years
UPDATE : Things are now working !
Thanks to deep, I installed node.js then got a TZInfo::DataSourceNotFound error wich got resolved by adding
gem 'tzinfo-data', platforms: [:mingw, :mswin]
andbundle update
.Thank you sir !
First of all, I am a complete beginner on rails (just so that you get how beginner I am : I feel as being an expert for just posting here) and this is my first question here so please excuse me if I'm not very clear.
So, I am a windows 7 user, learning rails with the One Month course and I encounter an error while trying to :
$ rake routes rake aborted! ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git hub.com/sstephenson/execjs for a list of available runtimes. c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7:in `<top (re quired)>' c:/Users/Marc Montagne/Desktop/pinteresting/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)
or
$ rails server c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/run times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn available) from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l ib/execjs.rb:5:in `<module:ExecJS>' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l ib/execjs.rb:4:in `<top (required)>' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0 /lib/uglifier.rb:3:in `require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0 /lib/uglifier.rb:3:in `<top (required)>' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:72:in `require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:72:in `block (2 levels) in require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:70:in `each' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:70:in `block in require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:59:in `each' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler/runtime.rb:59:in `require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/ lib/bundler.rb:132:in `require' from c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7 :in `<top (required)>' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands/commands_tasks.rb:79:in `require' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands/commands_tasks.rb:79:in `block in server' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands/commands_tasks.rb:76:in `tap' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands/commands_tasks.rb:76:in `server' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands/commands_tasks.rb:40:in `run_command!' from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4 /lib/rails/commands.rb:17:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>'
All that I understand is that I have a problem with ExecJS. As a total beginner I don't even know what ExecJS is.
I read the great thread #12520456 and while editing runtimes.rb didn't fix my problem, it still gave me a better understanding of the situation and the willingness to solve my problem by fixing it and not "ignoring it" by adding node.js especially given the fact that I could run my server before and that I want to fix what I basically broke.
What I mean by that is that I think I did something wrong when editing the PATH (I don't even know what this is) of my Windows environment for fixing an issue I had with installing Heroku. I remember editing that part as I read it somewhere and while it seemed to have fixed my Heroku issue I think it messed up the rest.
Thank you in advance for your help and understanding.
-
AlphonseJr almost 10 yearsHello Santosh. The line wasn't in my Gemfile (not even commented) so I manually added it and did the bundle install but I keep getting my error message.
-
Justin almost 10 years@Santosh...good answer. But I have had a few people get this error. This solution weirdly only helped resolve a few of the issues.
-
Santhosh almost 10 yearsNo, linux. Ubuntu to be precise.
-
Justin almost 10 yearsYep I think that's why. I believe the solution above worked on my virtual machine running linux, but when using Windows, ugh, the only solution was to edit the
runtimes.rb
file. :) -
AlphonseJr almost 10 yearsHello Justin, as said in my question, I've already been through the thread you indicate and did the runtimes.rb change with no results... My error message is ExecJS::RuntimeUnavailable and not ExecJS::RuntimeError as in the other thread. I don't know if that makes a difference.
-
AlphonseJr almost 10 yearsI am using windows 7 and I tried editing the runtimes.rb file. Isn't more an issue with a "path" ?
-
Phillipp over 8 yearsThis is not a good answer because therubyracer is discouraged to be used in production.
-
hananamar about 2 yearsI would recommend installing node using nvm rather than just installing node using apt, e.g. heynode.com/tutorial/install-nodejs-locally-nvm