Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Generate a Scaffold

Brandon Keene
Brandon Keene
7,217 Points

Can't reach todo_lists. Error: ExecJS::RuntimeUnavailable in TodoLists#index

First things first: I'm running a full install under linux rather than in the VM. That said, I haven't had much trouble until now. I've followed along with Jason, but when it came time to go to localhost:3000/todo_lists I get a rather ugly error instead of a nice scaffold page:

ExecJS::RuntimeUnavailable in TodoLists#index Showing /home/username/projects/odot/app/views/layouts/application.html.erb where line #6 raised:

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (in /home/username/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/turbolinks-2.5.3/lib/assets/javascripts /turbolinks.js.coffee)

Extracted source (around line #6):

 <title>Odot</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>

Per the advice on this page, I ran gem install execjs gem install therubyracer bundle

...to no effect. Anyone have a suggestion that might get me back on track?

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

It seems like you need to install NodeJS on your system. In Ubuntu it would be sudo apt-get install nodejs

Brandon Keene
Brandon Keene
7,217 Points

I considered that. The folks on the linked post seemed pretty divided between therubyracer and nodejs. I'll go ahead and install nodejs though and report back.

Should I remove therubyracer and execjs?

Brandon Keene
Brandon Keene
7,217 Points

Yep, that fixed it.

Could you explain what was wrong and why that fixed it?

And thank you very much!

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

In short, these allow you to use JavaScript in your Rails applications and run them locally. I think NodeJS is more useful, since you may in your later career try coding JS apps using NodeJS. Also, on all my machines, installing node always helped with this error right away, therubyracer did not.

Brandon Keene
Brandon Keene
7,217 Points

Thanks so much for letting me know!

Anthony Pham
Anthony Pham
6,770 Points

Will NodeJS work on Windows as well? If so, what would be the process of using NodeJS after getting it from rubygems.org. I can't seem to get it to work.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Anthony, stop using Windows for Rails development as soon as you can - it will lead you nowhere, lots of errors and lack of help online, since Rails devs don't use Windows. I suggest moving to Ubuntu (dual boot or VMWare Player). I can't really help you in any other way, because I have no idea how to make it work in Windows.