在 cygwin (windows7) 上运行 Rails 入门博客的 ExecJS::RuntimeError [英] ExecJS::RuntimeError running the Getting Started with Rails blog on cygwin (windows7)

查看:44
本文介绍了在 cygwin (windows7) 上运行 Rails 入门博客的 ExecJS::RuntimeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 cygwin (windows7) 上运行 Rails 入门博客.我收到以下错误消息:

I am trying to run the Getting Started with Rails blog on cygwin (windows7). I get the following error message:

ExecJS::Welcome#index 中的运行时错误

ExecJS:: RuntimeError in Welcome#index

module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\tmp\execjs20130903-50672-1vn7gqc.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

  (in /usr/lib/ruby/gems/1.9.1/gems/turbolinks-1.3.0/lib/assets/javascripts   /turbolinks.js.coffee)

节点已安装.

这是在

$rails generate controller welcome index
$rails s

我在 cygwin 上运行 Rails 4.0知道为什么会发生这种情况吗?

I am running Rails 4.0 on cygwin Any ideas why this might be happening?

谢谢

umbregachoong

umbregachoong

推荐答案

我遇到了这个错误,它与临时文件的路径错误有关.我能够通过更改 \gems\[ruby version]\gems\execjs-2.0.2\lib\execjs 中的以下两个文件来修复它.(可能在 \usr\lib\ruby\ 中找到,但这取决于您的 Ruby 的安装方式.我使用的是 RVM,所以我的不同.)

I encountered this error and it had to do with the path to the temp file being wrong. I was able to fix it by changing the following two files in \gems\[ruby version]\gems\execjs-2.0.2\lib\execjs. (Possibly found in \usr\lib\ruby\, but that depends on how your Ruby is installed. I'm using RVM so mine is different.)

compile_to_tempfile(source) do |file|
     extract_result(@runtime.send(:exec_runtime, file.path))
  end
end

应该改为

compile_to_tempfile(source) do |file|
    filepath = file.path
    if ExecJS.cygwin? && @runtime.name == "JScript"
      IO.popen("cygpath -m " + file.path) { |f| filepath = f.read }
      filepath = filepath.gsub("\n","")
    end
    extract_result(@runtime.send(:exec_runtime, filepath))
  end
end

module.rb

在最后两个 end 之前添加这个.

def cygwin?
  @cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
end

在这之后重启你的 Rails 服务器,幸运的话它应该可以工作了.

After this restart your Rails server and with any luck it should work.

来源:https://github.com/sstephenson/execjs/issues/78

这篇关于在 cygwin (windows7) 上运行 Rails 入门博客的 ExecJS::RuntimeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆