Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

therubyracer or nodejs, which should I use?

I am following the ruby on rails getting started guide on a new install of Ubuntu 12.10. I'm up to running rake db:create but I get the following error:

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

I've searched around and the suggested solutions (see list below) are to install some either therubyracer or nodejs but they don't explain why.

  • rake db:create - Could not find a JavaScript runtime
  • Rails 3.1 error - Could not find a JavaScript runtime?
  • http://datacodescotch.blogspot.com.au/2011/11/rails-31-spree-and-rake-aborted-could.html
  • http://www.blog.railshouse.com/

Before I go installing stuff I want to know what the differences are between these JavaScript runtimes and why I would choose one over the other?

Update:

I just read https://github.com/sstephenson/execjs (I know I should have read this first, sorry) and it seems to me that execjs is not a JavaScript runtime and I already have it... so it's down to therubyracer and nodejs ... please excuse my ignorance, I've amended my question

In addition to Intrepidd's answer:

The ruby on rails getting started guide supports Intrepidd's answer. See section 4.1 "Starting up the Web Server" where it says:

Rails adds the therubyracer gem to Gemfile in a commented line for new apps and you can uncomment if you need it.

For the rails noobs out there (like me) the GemFile is in the root folder of your rails application. After uncommenting that line in my GemFile I had to run bundle install to install therubyracer gem.

like image 376
Dean Avatar asked Feb 12 '13 09:02

Dean


2 Answers

You should prefer NodeJS over therubyracer because NodeJS is memory efficient, but it might not be as easy to install, although on Mac OS it's easy so it is on Ubuntu.

like image 110
rubyonrails3 Avatar answered Oct 12 '22 14:10

rubyonrails3


On a *NIX system, you can just uncomment the gem "therubyracer" in the gemfile and you're good to go, this is the easiest.

like image 26
Intrepidd Avatar answered Oct 12 '22 13:10

Intrepidd