What is Javascript-Runtime for?

80 views
Skip to first unread message

Peter

unread,
Apr 4, 2013, 8:14:01 AM4/4/13
to rubyonra...@googlegroups.com
Hello Everyone,

Can anyone please describe the relationship of javascript-runtime to Ruby on Rails? In Mac OSX, I do not get this error, but in Linux for every new project generated by "rails new", I get:
play$ rails s
//.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

I know the solution; either install therubyracer or nodejs gems. But I am not sure I understand fully why it works. If I install this in a production environment server, I do not need either one of these. And my browser definitely interprets javascript built in. So how does this fit in to everything? Is my premise incorrect? Thank you.

Peter

Frederick Cheung

unread,
Apr 4, 2013, 8:39:43 AM4/4/13
to rubyonra...@googlegroups.com
There are asset pipeline dependencies here: for example uglifyjs (for minifying javascript) and coffeescript are both written in javascript. Both of these two things happen serverside (almost: you can compile the assets somewhere other than your deployment machines, and copy the finished product either to the deployment machines or to the CDN of your choice)

Fred

Peter

unread,
Apr 5, 2013, 2:01:50 PM4/5/13
to rubyonra...@googlegroups.com
Thanks for replying, Frederick. So help me understand this: javascript-runtime is actually the javascript interpreter. Right? But what is odd is when I install node-js this solves my problem. And I thought node-js was written in javascript. Therefore, it itself requires an interpreter. Did I get this wrong? So how does installing node-js, a javascript script, solve the problem of not having a javascript interpreter to begin with?

Thanks again.

Colin Law

unread,
Apr 5, 2013, 5:04:28 PM4/5/13
to rubyonra...@googlegroups.com
On 5 April 2013 19:01, Peter <pe...@poproj.com> wrote:
> Thanks for replying, Frederick. So help me understand this:
> javascript-runtime is actually the javascript interpreter. Right? But what
> is odd is when I install node-js this solves my problem. And I thought
> node-js was written in javascript. Therefore, it itself requires an
> interpreter. Did I get this wrong? So how does installing node-js, a
> javascript script, solve the problem of not having a javascript interpreter
> to begin with?

Node.js is based on the Google's javascript engine, I believe, which
is not written in javascript. With it comes a javascript library to
extend the features (which is run by the javascript engine of course).

Colin

>
> Thanks again.
>
>
> On Thursday, April 4, 2013 5:39:43 AM UTC-7, Frederick Cheung wrote:
>>
>>
>>
>> On Thursday, April 4, 2013 1:14:01 PM UTC+1, Peter wrote:
>>>
>>> Hello Everyone,
>>>
>>> Can anyone please describe the relationship of javascript-runtime to Ruby
>>> on Rails? In Mac OSX, I do not get this error, but in Linux for every new
>>> project generated by "rails new", I get:
>>>>>
>>>>> play$ rails s
>>>>>
>>>>>
>>>>> //.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in
>>>>> `autodetect': Could not find a JavaScript runtime. See
>>>>> https://github.com/sstephenson/execjs for a list of available runtimes.
>>>
>>>
>>> I know the solution; either install therubyracer or nodejs gems. But I am
>>> not sure I understand fully why it works. If I install this in a production
>>> environment server, I do not need either one of these. And my browser
>>> definitely interprets javascript built in. So how does this fit in to
>>> everything? Is my premise incorrect? Thank you.
>>
>>
>> There are asset pipeline dependencies here: for example uglifyjs (for
>> minifying javascript) and coffeescript are both written in javascript. Both
>> of these two things happen serverside (almost: you can compile the assets
>> somewhere other than your deployment machines, and copy the finished product
>> either to the deployment machines or to the CDN of your choice)
>>
>> Fred
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/MhmcXGWzJDQJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

henrique matias

unread,
Apr 5, 2013, 4:54:09 PM4/5/13
to rubyonra...@googlegroups.com
just a small add to the topic, node.js is not written in javascript.. it allows you to write your stuff, using javascript.


actually its very compatible with coffee script which is, in my opinion, way more fun than javascript ( :



On 5 April 2013 19:01, Peter <pe...@poproj.com> wrote:

--

botp

unread,
Apr 6, 2013, 8:01:00 AM4/6/13
to rubyonra...@googlegroups.com
On Thu, Apr 4, 2013 at 8:14 PM, Peter <pe...@poproj.com> wrote:
I know the solution; either install therubyracer or nodejs gems.


try,
  bundle install --without assets
 
 If I install this in a production environment server, I do not need either one of these. And my browser definitely interprets javascript built in. So how does this fit in to everything? Is my premise incorrect?


you are correct.

kind regards -botp

Frederick Cheung

unread,
Apr 7, 2013, 6:35:04 AM4/7/13
to rubyonra...@googlegroups.com


On Friday, April 5, 2013 7:01:50 PM UTC+1, Peter wrote:
Thanks for replying, Frederick. So help me understand this: javascript-runtime is actually the javascript interpreter. Right? But what is odd is when I install node-js this solves my problem. And I thought node-js was written in javascript. Therefore, it itself requires an interpreter. Did I get this wrong? So how does installing node-js, a javascript script, solve the problem of not having a javascript interpreter to begin with?

node-js is both both google V8 javascript engine plus some libraries (much as for example ruby is the ruby interpreter plus a bunch of standard library stuff)

Fred 

Peter

unread,
Apr 7, 2013, 9:38:49 PM4/7/13
to rubyonra...@googlegroups.com
Thank you, everyone. This was an issue only in my Fedora laptop. In my OSX, not a problem at all. I knew all along that installing therubyracer or nodejs would fix this, I just didn't know the "why" since I thought these weren't javascript interpreters; that they themselves were written in javascript that required a javascript interpreter.

That said, I installed therubyracer and I did see libv8 being installed along with it. This I believe is the javascript interpreter so it now makes sense and I understand that it is used only for compiling the assets in asset pipeline. Thanks again for everyone's input.

p

Manish Chakravarty

unread,
Apr 8, 2013, 11:29:55 AM4/8/13
to rubyonra...@googlegroups.com
I hate to add to the confusion, but therubyracer is now not
recommended on Heroku.
What do you suggest we do ? I typically precompile assets and push it.
Is this the recommended way?
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/0fNqV41Nu98J.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Best,
Manish Chakravarty

Blog | Twitter | LinkedIn

Jordon Bedwell

unread,
Apr 8, 2013, 11:35:38 AM4/8/13
to rubyonra...@googlegroups.com
On Mon, Apr 8, 2013 at 10:29 AM, Manish Chakravarty <manis...@gmail.com> wrote:
I hate to add to the confusion, but therubyracer is now not
recommended on Heroku.
What do you suggest we do ? I typically precompile assets and push it.
Is this the recommended way?

Reply all
Reply to author
Forward
0 new messages