【问题标题】:Possible to get Rails 4 working on Windows?可以让 Rails 4 在 Windows 上运行吗?
【发布时间】:2013-05-24 16:25:34
【问题描述】:

我正在开发一个 Rails 4(使用候选发布版)项目,现在需要与 Windows 机器上的某个人协作。但是,我什至无法启动基本网页:(。即使使用 Ruby 2.0 安装 sqlite3 也很痛苦。现在,当我尝试启动网页时(我刚刚创建了一个虚拟的 /home/index 控制器并查看),我收到此错误:

Showing C:/Users/me/RubymineProjects/test_project/app/views/layouts/application.html.erb where line #6 raised:

  (in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-1.1.1/lib/assets/javascripts/turbolinks.js.coffee)

Extracted source (around line #6):
3  <head>
4    <title>TestProject</title>
5    <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
6    <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7    <%= csrf_meta_tags %>
8  </head>
9  <body>

Rails 4 还没有为 Windows 做好准备吗?使用 Ruby 2.0.0p195。

更新:根据@szines 的要求,这是

的网页输出
http://localhost:3000/rails/info/properties:
Ruby version    2.0.0 (x64-mingw32)
RubyGems version    2.0.3
Rack version    1.5
Rails version   4.0.0.rc1
JavaScript Runtime  JScript
Active Record version   4.0.0.rc1
Action Pack version 4.0.0.rc1
Action Mailer version   4.0.0.rc1
Active Support version  4.0.0.rc1
Middleware  
ActionDispatch::Static
Rack::Lock
#<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x000000036b85c0>
Rack::Runtime
Rack::MethodOverride
ActionDispatch::RequestId
Rails::Rack::Logger
ActionDispatch::ShowExceptions
ActionDispatch::DebugExceptions
ActionDispatch::RemoteIp
ActionDispatch::Reloader
ActionDispatch::Callbacks
ActiveRecord::Migration::CheckPending
ActiveRecord::ConnectionAdapters::ConnectionManagement
ActiveRecord::QueryCache
ActionDispatch::Cookies
ActionDispatch::Session::CookieStore
ActionDispatch::Flash
ActionDispatch::ParamsParser
Rack::Head
Rack::ConditionalGet
Rack::ETag
Warden::Manager
Application root    C:/Users/me/RubymineProjects/test_project
Environment development
Database adapter    sqlite3
Database schema version 20130523073322

【问题讨论】:

  • 是否可以在没有 turbolinks 的情况下运行它?您需要 turbolinks 宝石吗?
  • 是的,对不起,我忘了提!我确实想要涡轮链接。
  • 是否包含错误信息?
  • @JesseWolgamott - 我在上面发布的内容不是错误消息吗?你问是否有更具体的错误信息?不,这就是我的全部。
  • 你的运行环境是什么?开发模式下调用这个url就可以得到:localhost:3000/rails/info/properties

标签: ruby-on-rails ruby-on-rails-4 ruby-2.0


【解决方案1】:

&lt;%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" =&gt; true %&gt;

把这个改成:

&lt;%= stylesheet_link_tag "defaults", media: "all", "data-turbolinks-track" =&gt; true %&gt;

它应该工作。

如果有人可以对此提供解释,那就太好了。

更多信息:

ExecJS::RuntimeError in Users#index (RoR)

ExecJS and could not find a JavaScript runtime

【讨论】:

  • 嗨,这对我不起作用,但如果我在它下面的行中也将“应用程序”更改为“默认值”,它会在之后起作用!
  • 我尝试了 airpaulg 的建议,它对我有用。您需要同时更改两者。
  • 安装 node.js——它是永久的解决方案(确保在 windows 环境中的路径下包含 npm/bin )。通过使用“默认值”,您将包含不存在的 defaults.js。检查网络下的浏览器控制台 404-not found.
【解决方案2】:

只需安装 node.js,问题就会消失。

说明: 如果您尝试预编译资产,您将获得以下跟踪:

(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'
...

如您所见,ExecJS 存在问题。 ExecJS 允许您从 Ruby 运行 JavaScript 代码,它需要在您的系统上安装一个 JS 解释器。这是受支持的解释器的a list。通常,您可以使用只是 V8 的 ruby​​racer,但是在 windows 下编译 V8 时会出现问题。所以你可以选择另一个选项——NodeJS。当您安装 NodeJS 并将其添加到您的 PATH 时,ExecJS 将自动使用它。

【讨论】:

    【解决方案3】:

    更改下一行

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

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

    有效。

    你可以安装node.js

    【讨论】:

    • 我在使用 Railsinstaller(今天的最新版本)在 Windows 上运行 Rails 时遇到了同样的问题。用“默认值”替换“应用程序”是可行的。没有安装 node.js。
    • 确保在路径中添加“npm/bin”(Windows 环境)
    【解决方案4】:

    让 Turbolinks 在 Windows 8 x64 上运行的实际解决方案发布在 ExecJS::RuntimeError on Windows trying to follow rubytutorial,选项 3。

    【讨论】:

      【解决方案5】:

      我遇到这个问题已经有一段时间了,在 Windows 上 jquery 和 coffee 脚本在他们的最新更新中不起作用,最后我发现这个很棒的方法可以完美地工作,不需要下载节点或转义 //require tree .因此,您所需要的只是将位于 execjs 中的 runtimes.rb 中的设置配置为如下所示 - 您会发现这部分几乎没有区别,可以修复它们,您会很高兴的。

      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
      

      您可以观看此视频以获得详细的解决方案。 https://www.youtube.com/watch?v=N5i94L17KPo

      【讨论】:

        猜你喜欢
        • 2013-11-28
        • 1970-01-01
        • 1970-01-01
        • 2012-06-20
        • 2012-05-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-16
        相关资源
        最近更新 更多