Possible to get Rails 4 working on Windows?

杀马特。学长 韩版系。学妹 提交于 2019-11-28 23:41:22
Yash Agarwal

<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>

Change this to :

<%= stylesheet_link_tag "defaults", media: "all", "data-turbolinks-track" => true %>

It should work.

It will be great if someone can provide explanation for this.

More info:

ExecJS::RuntimeError in Users#index (RoR)

ExecJS and could not find a JavaScript runtime

Just install node.js and the problem will gone.

Explanation: If you'll try to precompile assets, you'll get the following trace:

(in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-1.3.0/lib/assets/javascripts/turbolinks.js.coffee)
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:142:in `exec_runtime'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:28:in `block in exec'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile'
...

As you can see, there is a problem with ExecJS. ExecJS lets you run JavaScript code from Ruby and it requires one of the JS interpreters to be installed on your system. Here's a list of supported interpreters. Usually, you can use therubyracer which is just V8 but there are problems with compiling V8 under the windows. So you can choose another option - NodeJS. ExecJS will use it automatically when you'll install NodeJS and add it to your PATH.

changing following line

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

to

<%= javascript_include_tag "defaults", "data-turbolinks-track" => true %>

works.

OR

you can install node.js

GerardV

The actual solution for getting Turbolinks to work on Windows 8 x64 is posted at ExecJS::RuntimeError on Windows trying to follow rubytutorial, option 3.

I have been facing this problem for a while and it's that on windows jquery and coffee script are not functional in their latest update and finally i found this wonderful method that worked perfectly without the need to download node or escape //require tree. So all you need is configure the settings in your runtimes.rb which lives in execjs to be like this- you will find this part with few differences fix them and you'll be good to go.

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

You can watch this video for detailed solution. https://www.youtube.com/watch?v=N5i94L17KPo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!