Repository navigation
Missing js runtime fix 3 1 stable - #4407
brentsowers1 wants to merge 1 commit into
Conversation
…ave a Javascript runtime (Linux without node js). Without this gem an error is reported by execjs
|
I'd rather not have Rails do JavaScript runtime detection, especially since this is for envjs functionality. Rather than doing runtime detection, can we just add comments to the generated gemfile that tell the user what to do depending on their OS? |
|
I agree that having to do the runtime detection in the Rails generator script is not ideal. But as it stands now, a newly created Rails project will not run on Linux (unless they've previously installed node.js) without the user having to look at the error message, go to the URL in the execjs error message, and install one of the gems listed there. This is not a problem for anyone in here looking at the Rails source code, but this is going to be one more roadblock for users totally new to Rails, who at this point are probably thinking "Rails was supposed to be easy to get up and running!". They're probably already overwhelmed by bundle, rake, and rails. This is one more thing to confuse them. If they do actually want to get it running, they're going to have to decide from the list of 6 things on that list. I imagine they won't want to install node.js, or Spidermonkey, I know when I first ran in to this I was a little offended that I might have to install node.js for something in Rails. So they'll want to go the gem route, but then, they have to decide on which one. Then, they'll have to at least get some idea of how gems work, and then learn a little about bundler and how to add gems to the Gemfile. And this will be the users very first impression of actually using Rails. To me this is too much to ask when it can all be solved by simply checking if one of the executables is on the system in Rails. And I understand being concerned about solving essentially an execjs problem in Rails. However Rails requires execjs, so an execjs problem is essentially a Rails problem. |
|
Actually, technically, rails does not require execjs (execjs is not a dependency, direct or indirect, of the Rails gem), although Rails new app generator generates a local app Gemfile that, by default, does depend (indirectly) on execjs. It is theoretically possible to use Rails without execjs though (without the asset pipeline). However, @tenderlove . I agree that Rails having to detect JS runtime, duplicating execjs code, is unfortunate. What do you think about actually making execjs a dependency of railties -- then the generator would be able to ask ExecJS::Runtimes.autodetect, instead of having to duplicate that code itself. The downside is another dependency (that isn't actually used for anything BUT this in Rails code proper); however, execjs is a pretty small, simple, and pure ruby gem. And the way to be sure if execjs will find a runtime is, well, to ask execjs, rather than try to execute seperate logic that one hopes will decide the same thing as (possibly future versions of) execjs. And as long as rails generator generates an app that needs execjs, the only way to get a 'rails new whatever' that can actually boot (like every newly generated rails app could before asset pipeline), is to check if execjs will find a runtime, and if not add therubyracer (or equivalent) to Gemfile. |
|
Could we just do platform detection and emit "good defaults" depending on the platform? That would let us avoid runtime detection. |
|
@tenderlove that seems reasonable, although not as reliable. The idea This could make a mistake -- someone on Win or OSX might not actually Worse, someone on linux might have node.js installed and not need Using execjs seems the RIGHT way to do it, but the cost is a On Thu, Jan 12, 2012 at 12:41 PM, Aaron Patterson
|
|
I think it's fine to assume that Linux requires therubyracer, even if node.js is installed, good suggestion @tenderlove |
... a Javascript runtime (Linux without node js). Without this gem an error is reported by execjs
Issues #412 and #4020
I've tested this on Ubuntu with and without nodejs, and on Windows, and it works correctly, the Gemfile contains a line for therubyracer only on Ubuntu without nodejs